Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
Swing / AWT / SWT
JTabbedPane color
N Ganesh
Greenhorn
Posts: 5
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Can I have the same, background and foreground color, for all the panes in a JTabbedPane whether they are selected or not.
Currently, if I set background color as orange and foreground color as white, I am getting that combination for the unselected panes.
But the selected pane's background is coming as blue only (the default for
java
).
Kindly help me out on this.
N Ganesh
Craig Wood
Ranch Hand
Posts: 1535
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import java.awt.*; import javax.swing.*; import javax.swing.plaf.ColorUIResource; public class TabbedPaneTest { private JTabbedPane getTabbedPane() { String[] keys = { "unselectedBackground", "foreground", "selected", "focus", "contentAreaColor" }; Color[] colors = { Color.green.darker(), Color.blue, Color.pink, Color.red, Color.pink }; for(int j = 0; j < keys.length; j++) { String key = "TabbedPane." + keys[j]; System.out.println(keys[j] + " = " + UIManager.getColor(key)); UIManager.put(key, new ColorUIResource(colors[j])); } JTabbedPane tabbedPane = new JTabbedPane(); for(int j = 0; j < 4; j++) tabbedPane.addTab("tab " + (j+1), new JLabel("tab " + (j+1), JLabel.CENTER)); return tabbedPane; } public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new TabbedPaneTest().getTabbedPane()); f.setSize(400,400); f.setLocation(200,200); f.setVisible(true); } }
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JComboBox: Opaque problem
foreground color
Can I change the back/foreground color of a disabled JComboBox?
JTabbedPane
How to give color for JRadioButtons?
More...