Match theme color in MenuBarCustomizer?

Post here questions and problems related to oXygen frameworks/document types.
queshaw
Posts: 41
Joined: Wed Aug 08, 2007 5:56 am

Match theme color in MenuBarCustomizer?

Post by queshaw »

Hi,

I know very little Swing. How can I match the theme color when adding a menu and menu item? My latest attempt:

Code: Select all

                    Color bg = (Color) UIManager.get("MenuBar.background");
                    Color fg = (Color) UIManager.get("MenuBar.foreground");
                    UIManager.put("MenuItem.background", bg);
                    UIManager.put("MenuItem.foreground", fg);
                    UIManager.put("Menu.background", bg);
                    UIManager.put("Menu.foreground", fg);
                    JMenu menu = new JMenu("Some");
                    JMenuItem item = new JMenuItem(createSyncAction(...));
                    item.setSelected(false);
                    item.setMnemonic(KeyEvent.VK_ALT | KeyEvent.VK_S);
                    item.setBackground(bg);
                    item.setForeground(fg);
                    item.setOpaque(true);
                    menu.add(item);
                    menu.setSelected(false);
                    menu.setMnemonic(KeyEvent.VK_ALT | KeyEvent.VK_A);
                    menu.setBackground(bg);
                    menu.setForeground(fg);
                    menu.setOpaque(true);
                    menuBar.add(menu, menuBar.getMenuCount() - 1);
I also tried menuBar.getBackground()/getForeground() instead of UIManager.get.
Kendall
Radu
Posts: 9058
Joined: Fri Jul 09, 2004 5:18 pm

Re: Match theme color in MenuBarCustomizer?

Post by Radu »

Hi Kendall,

Instead of JMenu you should create an Oxygen specific ro.sync.exml.workspace.api.standalone.ui.Menu.
After this avoid creating the JMenuItem, use the method javax.swing.JMenu.add(Action) to directly add the action to the menu.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
queshaw
Posts: 41
Joined: Wed Aug 08, 2007 5:56 am

Re: Match theme color in MenuBarCustomizer?

Post by queshaw »

Thank you!
Post Reply