Home > Archive > Java Help > September 2004 > How to set color of text font in JTree
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to set color of text font in JTree
|
|
| BoomerangThree 2004-09-18, 3:59 pm |
| 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;
| |
| Larry Barowski 2004-09-19, 3:58 pm |
|
"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; } });
| |
| BoomerangThree 2004-09-20, 9:03 pm |
| Thanks. 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; } });
>
>
| |
| David Johnson 2004-09-21, 3:59 pm |
| If 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;
>
>
|
|
|
|
|