DevFaqOWColorText

Revision as of 15:02, 9 December 2009 by T h (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

How to use color text in Output Window

You can use IO extension classes like IOColorPrint, IOColorLines. Default colors can be changed via IOColors.

InputOutput io = IOProvider.getDefault().getIO("test");

// change default color for output in corresponding tab
if (IOColors.isSupported(io)) {
    IOColors.setColor(io, IOColors.OutputType.OUTPUT, Color.GRAY);
}

// print line in specific color
if (IOColorLines.isSupported(io)) {
    IOColorLines.println(io, "Green line", Color.GREEN);
}


public class L implements OutputListener {
...
}

// print parts of line in specific color
if (IOColorPrint.isSupported(io)) {
    IOColorPrint.print(io, "Green part", Color.GREEN);
    IOColorPrint.print(io, " pink part", Color.PINK);
    IOColorPrint.print(io, " hyperlink with custom color", new L(), false, Color.MAGENTA);
}

Applies to: NetBeans 6.7 or later, (IOColorPrint 6.8 or later).

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo