Solved

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

Posted on 2007-03-20
16
853 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
ID: 18762368
UIDefaults.put("TabbedPane.background", Color.white);
UIDefaults.put("TabbedPane.focus", Color.red);
0
 
LVL 92

Accepted Solution

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

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

Author Comment

by:akoifman
ID: 18763429
Can I control tab font size, style?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 86

Expert Comment

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

Expert Comment

by:objects
ID: 18767198

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
ID: 18768996
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
ID: 18769001
This makes all selected tabs the same color:
UIDefaults.put("TabbedPane.selected", Color.yellow);
 
0
 
LVL 92

Expert Comment

by:objects
ID: 18769023
yes, change the UIdefault between the creation of the two tabs

0
 
LVL 86

Expert Comment

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

Author Comment

by:akoifman
ID: 18770408
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
ID: 18770425
>>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
ID: 18770441
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
ID: 18775030
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
ID: 18775069
>>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
ID: 18775862
Yes, I learened something and find it more convinient than setBackground().  THANKS!
0
 
LVL 92

Expert Comment

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

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

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

778 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