Solved

JTabbedPane active tab setting do not work (except FG color)

Posted on 2007-03-20
16
848 Views
Last Modified: 2008-03-10
Hi,

I have a JTabbedPane panel.  I have very little control of an active tab display.  The only thing I can do with it is to set a foreground (label) color.  If I set an active tab background color or set label font size or style - it does not work.  

I cannot believe that these methods do not work.

Thanks.
0
Comment
Question by:akoifman
  • 6
  • 5
  • 5
16 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
UIDefaults.put("TabbedPane.background", Color.white);
UIDefaults.put("TabbedPane.focus", Color.red);
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
Comment Utility
before creating your tab pane set the selected tab background using:

UIDefaults.put("TabbedPane.selected", Color.yellow);
0
 

Author Comment

by:akoifman
Comment Utility
Can I control tab font size, style?
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
UIDefaults.put("TabbedPane.font", someFont);
0
 
LVL 92

Expert Comment

by:objects
Comment Utility

you can change the font used using

tabs.setFont(font);

But you cannoty change the font just for the selected tab.
0
 

Author Comment

by:akoifman
Comment Utility
Hi Objects,

I am almost there.  

I have a two-row hierarchical tabs.  Can I set an active tab BG in top row different from an active tab BG in the lower row?  Thanks!
0
 

Author Comment

by:akoifman
Comment Utility
This makes all selected tabs the same color:
UIDefaults.put("TabbedPane.selected", Color.yellow);
 
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
yes, change the UIdefault between the creation of the two tabs

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
I wonder why my comments were ignored - especially since it was the *background* you were asking about?
0
 

Author Comment

by:akoifman
Comment Utility
Hi CEHJ,

Both you and OBJECT provided the solution.  This did not work for me UIDefaults.put("TabbedPane.focus", Color.red);

I had a few follow up questions, and I felt that OBJECT helped me with those.  I wish I can give you some extra points.  If this can be done, I'll give you 100 points.

Thank you!
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>Both you and OBJECT provided the solution.

Yes, that's precisely my point

>> This did not work for me UIDefaults.put("TabbedPane.focus", Color.red);

That's not the part that deals with the background though
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
question seemed quite clearly about the *active* tab background was it not, the tab background itself can be easily changed without worrying about UIDefaults.
0
 

Author Comment

by:akoifman
Comment Utility
I think Object is correct.  He provide the answer:
UIDefaults.put("TabbedPane.selected", Color.yellow);

Cehj, thanks a lot for your effort.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>Cehj, thanks a lot for your effort.

No problem - i see you've put my code to use in your next question
0
 

Author Comment

by:akoifman
Comment Utility
Yes, I learened something and find it more convinient than setBackground().  THANKS!
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
> Yes, I learened something and find it more convinient than setBackground().  THANKS!

user beware, they are not the same thing :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now