Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

How to set color of text font in JTree
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;



Report this thread to moderator Post Follow-up to this message
Old Post
BoomerangThree
09-18-04 08:59 PM


Re: How to set color of text font in JTree
"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; } });



Report this thread to moderator Post Follow-up to this message
Old Post
Larry Barowski
09-19-04 08:58 PM


Re: How to set color of text font in JTree
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; } });
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
BoomerangThree
09-21-04 02:03 AM


Re: How to set color of text font in JTree
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;
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
David Johnson
09-21-04 08:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:17 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.