summaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java')
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java70
1 files changed, 70 insertions, 0 deletions
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java
index 16e22ac5286..1848c1f162d 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.ContainerListener;
import java.awt.event.MouseEvent;
@@ -46,6 +47,8 @@ import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.JToolBar;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
@@ -225,4 +228,71 @@ public class MetalToolBarUI extends BasicToolBarUI
super.mouseDragged(e);
}
}
+
+ /**
+ * Installs the UI on the toolbar. This calls super and sets the rollover
+ * property according to the <code>UIManager</code> property
+ * &quot;ToolBar.isRollover&quot;.
+ *
+ * @param c the component to install the UI on
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ if (c instanceof JToolBar)
+ {
+ JToolBar tb = (JToolBar) c;
+ tb.setRollover(UIManager.getBoolean("ToolBar.isRollover"));
+ }
+ }
+
+ /**
+ * Uninstalls the UI from the toolbar. This calls super and resets the
+ * rollover property.
+ *
+ * @param c the component to uninstall the UI from
+ */
+ public void uninstallUI(JComponent c)
+ {
+ if (c instanceof JToolBar)
+ {
+ JToolBar tb = (JToolBar) c;
+ tb.setRollover(false);
+ }
+ super.uninstallUI(c);
+ }
+
+ /**
+ * Paints the background of the component if necessary and then calls
+ * <code>paint(g, c)</code>.
+ *
+ * This is overridden to implement the OceanTheme gradient when an OceanTheme
+ * is installed.
+ *
+ * @param g the graphics to use
+ * @param c the component to paint.
+ *
+ * @since 1.5
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ // TODO: Sun's implementation uses the MenuBar.gradient here.
+ // I would consider this a bug, but implement it like this
+ // for compatibility.
+ if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
+ && UIManager.get("MenuBar.gradient") != null)
+ {
+ if (c.isOpaque())
+ {
+ MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+ SwingConstants.VERTICAL,
+ "MenuBar.gradient");
+ }
+ paint(g, c);
+ }
+ else
+ {
+ super.update(g, c);
+ }
+ }
}