Code Comments
Programming Forum and web based access to our favorite programming groups.I can't seem to find anything on how to set the background color of the text
in JTree.
Help???
private JTree getJTree() {
if (jTree == null) {
jTree = new JTree();
jTree.setBackground(new java.awt.Color(204,204,204));
jTree.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 12));
jTree.setForeground(java.awt.Color.lightGray);
}
return jTree;
Post Follow-up to this message
"BoomerangThree" <JM@Hotmail.com> wrote in message
news:10koqrc4odmf086@corp.supernews.com...
> I can't seem to find anything on how to set the background color of the
text
> in JTree.
That is controlled by the cell renderer. Try this:
tree.setCellRenderer(
new DefaultTreeCellRenderer() {
public Color getTextNonSelectionColor() {
return Color.lightGray; } });
Post Follow-up to this messageThanks. I will try this tonight.
"Larry Barowski" < larrybarATengDOTauburnDOTeduANDthatISall
> wrote in message
news:10kr7hqb0bdso2d@corp.supernews.com...
>
> "BoomerangThree" <JM@Hotmail.com> wrote in message
> news:10koqrc4odmf086@corp.supernews.com...
> text
>
> That is controlled by the cell renderer. Try this:
>
> tree.setCellRenderer(
> new DefaultTreeCellRenderer() {
> public Color getTextNonSelectionColor() {
> return Color.lightGray; } });
>
>
Post Follow-up to this messageIf you are using DefaultMutableTreeNode objects, you might also consider
using HTML to set text colours, e.g.:
result.add(new DefaultMutableTreeNode("<html><font color=\"blue\"><u>Cached
page (" + e.getCachedSize() + ")</u></font></html>"));
or add clickable hyperlinks:
result.add(new DefaultMutableTreeNode("<html><a href=" + e.getURL() + ">" +
e.getURL() + "</a></html>"));
Regards,
Dave.
"BoomerangThree" <JM@Hotmail.com> wrote in message
news:10koqrc4odmf086@corp.supernews.com...
>I can't seem to find anything on how to set the background color of the
>text in JTree.
>
> Help???
>
> private JTree getJTree() {
>
> if (jTree == null) {
>
> jTree = new JTree();
>
> jTree.setBackground(new java.awt.Color(204,204,204));
>
> jTree.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 12));
>
> jTree.setForeground(java.awt.Color.lightGray);
>
> }
>
> return jTree;
>
>
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.