Technology Network Community
Oracle Database
Fusion Middleware
Development Tools
Server & Storage Systems
Enterprise Management
Berkeley DB Family
Cloud Computing
Big Data
Business Intelligence
Migration and Modernization
E-Business Suite
PeopleSoft Enterprise
JD Edwards World
JD Edwards EnterpriseOne
User Productivity Kit Pro (UPK) and Tutor
Governance, Risk & Compliance (GRC)
Master Data Management (MDM)
Oracle CRM On Demand
On Demand: SaaS and Managed Applications
AutoVue Enterprise Visualization
Agile PLM
Endeca Experience Management
Fusion Applications
Archived Forums



Swing [Archive]

JMenu Appearance change

Hello,  I am just starting with developing in Java, and I have a problem, but cannot find the answer. I have a JApplet and using an menubar (JMenuBar) with submenu's (JMenu) and menuitems (JMenuItems)  I could manage to change the background and foreground selection colors of my menuitems with:  UIManager.put("MenuItem.selectionForeground", new javax.swing.plaf.ColorUIResource(selBgColor));  But I want also change the border colors of mu submenu's and the shadows of my submenu's and menubar to get rid of the dark color because my background of the submenu is white.  So how do I manipulate the border colors of JMenuBar, JMenu and JMenuItem and how dow I change the 3d effect and shadowcolors of JMenuBar, JMenu and JMenuItem.  I have read some articels about changing the look and feel but I cannot find those anwers. Can someone give me some clear examples how to change It or redirect me to articels with a clear explanation and examples in it  With kind regards, A new and enthousiastic programmer 

Hi  Stay enthousiastic as Java is a great language! To address your problem, I usually subclass a LAF (Look And Feel) theme, i.e. the DefaultMetalTheme.  I then overwrite the getPrimary1|2|3 and getSecondary1|2|3 methods to change the overall appearance. The hard thing about this is that it is not easy to see what  exactly is changed by these methods. SUNs source is badly documented here, although I am sure it would not be impossible to find resources that explain how it works.  To make live easier I put the targets that are changed in the comment of my overwritten methods. I found the influenced components by testing around with some clear (debug-)colors, and the comments are kind of simple and just give a rough idea, but might help. I post it here, so you can get an idea on it.      protected ColorUIResource getPrimary1() {         // borderMenu, title, labelText, statusBarText, borderTabs         return new ColorUIResource(30, 40, 40);     }       protected ColorUIResource getPrimary2() {         // desktop, active menus (rollovers), borderButton onClick         return new ColorUIResource(142, 172, 172);     }       protected ColorUIResource getPrimary3() {         // JFrame MenuBar, default directory  in trees         return new ColorUIResource(205, 215, 207);     }       protected ColorUIResource getSecondary1() {         // thin outer bordersTabs, Panel and Menu         return new ColorUIResource(100, 116, 116);     }       protected ColorUIResource getSecondary2() {         // linie unter menubar, Background buttonsOnClick, Tabs passiv         return new ColorUIResource(176, 203, 191);     }       protected ColorUIResource getSecondary3() {         // defaultGround Buttons, Panels, active Tabs, inner thin Border tabs         return new ColorUIResource(224, 236, 231);     }   -- Daniel Frey

Related Links

applet and getContentPane();
URGENT - drawing shapes in a scrollable panel
URGENT : Viewing HTML files & UNICODE characters
Data processing question...
Preventing JTree updates from uncompleted JTable edits
JEditorPane difference btwn 1.3 and 1.4?
Changing the Font in the tiltle bar of the Frame
URGENT!!!! Graphics in a JPanel
TextArea with scrollpane in ChatApplication
Border title cut off
aligning swing components
problem with JTree editing icons
how to compile java program
Dialog Box
JBuilder Frame Visibility