changeset 640:e3f026b1e200

Paint the menu bar Replace a no-op implementation of update() with a real implementaton. Reviewed-by: rkennke Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-September/003387.html
author Omair Majid <omajid@redhat.com>
date Wed, 26 Sep 2012 19:36:51 -0400
parents 73b984279227
children b515d481c39e
files dolphin/pom.xml dolphin/src/main/java/com/redhat/swing/laf/dolphin/menu/DolphinMenuBarUI.java dolphin/src/main/java/com/redhat/swing/laf/dolphin/showcase/MenuDemo.java dolphin/src/main/java/com/redhat/swing/laf/dolphin/themes/DolphinDefaultTheme.java dolphin/src/main/java/com/redhat/swing/laf/dolphin/themes/DolphinTheme.java
diffstat 5 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/dolphin/pom.xml	Mon Sep 24 20:29:50 2012 -0400
+++ b/dolphin/pom.xml	Wed Sep 26 19:36:51 2012 -0400
@@ -64,12 +64,12 @@
               com.redhat.swing.laf.dolphin.text,
               com.redhat.swing.laf.dolphin.themes,
               com.redhat.swing.laf.dolphin.table,
-              com.redhat.swing.laf.dolphin.tree
+              com.redhat.swing.laf.dolphin.tree,
             </Export-Package>
             <Private-Package>
               com.redhat.swing.laf.dolphin.showcase,
               com.redhat.swing.laf.dolphin.showcase.table,
-              com.redhat.swing.laf.dolphin.showcase.tree
+              com.redhat.swing.laf.dolphin.showcase.tree,
             </Private-Package>
             <!-- Do not autogenerate uses clauses in Manifests -->
             <_nouses>true</_nouses>
--- a/dolphin/src/main/java/com/redhat/swing/laf/dolphin/menu/DolphinMenuBarUI.java	Mon Sep 24 20:29:50 2012 -0400
+++ b/dolphin/src/main/java/com/redhat/swing/laf/dolphin/menu/DolphinMenuBarUI.java	Wed Sep 26 19:36:51 2012 -0400
@@ -39,6 +39,7 @@
 import java.awt.Graphics;
 
 import javax.swing.JComponent;
+import javax.swing.plaf.ColorUIResource;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.metal.MetalMenuBarUI;
 
@@ -50,6 +51,9 @@
     
     @Override
     public void update(Graphics g, JComponent c) {
-        // do nothing for now
+        if (c.isOpaque() && (c.getBackground() instanceof ColorUIResource)) {
+            g.setColor(c.getBackground());
+            g.fillRect(0, 0, c.getWidth(), c.getHeight());
+        }
     } 
 }
--- a/dolphin/src/main/java/com/redhat/swing/laf/dolphin/showcase/MenuDemo.java	Mon Sep 24 20:29:50 2012 -0400
+++ b/dolphin/src/main/java/com/redhat/swing/laf/dolphin/showcase/MenuDemo.java	Wed Sep 26 19:36:51 2012 -0400
@@ -37,11 +37,14 @@
 package com.redhat.swing.laf.dolphin.showcase;
 
 import java.awt.EventQueue;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
 
 import javax.swing.JFrame;
 import javax.swing.JMenuBar;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
+import javax.swing.KeyStroke;
 import javax.swing.UIManager;
 
 import com.redhat.swing.laf.dolphin.DolphinLookAndFeel;
@@ -92,6 +95,8 @@
         JMenu mnNewMenu = new JMenu("New menu");
         menuBar.add(mnNewMenu);
         
+        mnNewMenu.addSeparator();
+
         JMenu mnNewMenu_1 = new JMenu("New menu");
         mnNewMenu.add(mnNewMenu_1);
         
@@ -105,6 +110,7 @@
         mnNewMenu_1.add(mntmNewMenuItem_3);
         
         JMenuItem mntmNewMenuItem = new JMenuItem("New menu item");
+        mntmNewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK));
         mnNewMenu.add(mntmNewMenuItem);
         
         JMenuItem mntmNewMenuItem_1 = new JMenuItem("New menu item");
--- a/dolphin/src/main/java/com/redhat/swing/laf/dolphin/themes/DolphinDefaultTheme.java	Mon Sep 24 20:29:50 2012 -0400
+++ b/dolphin/src/main/java/com/redhat/swing/laf/dolphin/themes/DolphinDefaultTheme.java	Wed Sep 26 19:36:51 2012 -0400
@@ -243,6 +243,11 @@
     }
     
     @Override
+    public ColorUIResource getMenuBarBackgroundColor() {
+        return WINDOW_BACKGROUND;
+    }
+
+    @Override
     public ColorUIResource getMenuBackgroundColor() {
         return WHITE;
     }
@@ -433,7 +438,7 @@
         Object[] uiDefaults = {
 
                 "MenuBarUI", "com.redhat.swing.laf.dolphin.menu.DolphinMenuBarUI",
-                "MenuBar.background", getMenuBackgroundColor(),
+                "MenuBar.background", getMenuBarBackgroundColor(),
                 "MenuBar.border", new DolphinMenuBarBorder(),
                 
                 "MenuUI", "com.redhat.swing.laf.dolphin.menu.DolphinMenuUI",
--- a/dolphin/src/main/java/com/redhat/swing/laf/dolphin/themes/DolphinTheme.java	Mon Sep 24 20:29:50 2012 -0400
+++ b/dolphin/src/main/java/com/redhat/swing/laf/dolphin/themes/DolphinTheme.java	Wed Sep 26 19:36:51 2012 -0400
@@ -96,6 +96,7 @@
     
     public abstract ColorUIResource getWindowBackgroundColor();
     
+    public abstract ColorUIResource getMenuBarBackgroundColor();
     public abstract ColorUIResource getMenuBackgroundColor();
     public abstract ColorUIResource getMenuForegroundColor();
     public abstract ColorUIResource getTabAreaBackground();
@@ -138,4 +139,5 @@
 
     abstract public int getOneTouchButtonSize();
     abstract public int getOneTouchButtonOffset();
+
 }