home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.plaf.basic;
-
- import com.sun.java.swing.AbstractButton;
- import com.sun.java.swing.Icon;
- import com.sun.java.swing.JComponent;
- import com.sun.java.swing.JMenuItem;
- import com.sun.java.swing.JRadioButtonMenuItem;
- import com.sun.java.swing.LookAndFeel;
- import com.sun.java.swing.MenuElement;
- import com.sun.java.swing.MenuSelectionManager;
- import com.sun.java.swing.UIManager;
- import com.sun.java.swing.plaf.ComponentUI;
- import com.sun.java.swing.plaf.RadioButtonMenuItemUI;
- import com.sun.java.swing.plaf.UIResource;
- import java.awt.AWTEvent;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Insets;
- import java.awt.Point;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.event.MouseMotionListener;
- import java.io.Serializable;
-
- public class BasicRadioButtonMenuItemUI extends RadioButtonMenuItemUI implements Serializable {
- protected static Color pressedBackground = null;
- protected static Color pressedForeground = null;
- protected Icon menuArrow;
- protected Icon checkIcon;
- protected static final int defaultTextIconGap = 4;
- protected MouseListener mouseListener;
- protected MouseMotionListener mouseMotionListener;
- protected boolean oldBorderPainted;
-
- public static ComponentUI createUI(JComponent var0) {
- return new BasicRadioButtonMenuItemUI();
- }
-
- public void installUI(JComponent var1) {
- JRadioButtonMenuItem var2 = (JRadioButtonMenuItem)var1;
- this.initListeners(var1);
- this.addListeners(var1);
- var1.setOpaque(true);
- LookAndFeel.installBorder(var1, "MenuItem.border");
- this.oldBorderPainted = ((AbstractButton)var2).isBorderPainted();
- ((AbstractButton)var2).setBorderPainted((Boolean)UIManager.get("MenuItem.borderPainted"));
- LookAndFeel.installColorsAndFont(var1, "MenuItem.background", "MenuItem.foreground", "MenuItem.font");
- if (pressedBackground == null || pressedBackground instanceof UIResource) {
- pressedBackground = UIManager.getColor("MenuItem.pressedBackground");
- }
-
- if (pressedForeground == null || pressedForeground instanceof UIResource) {
- pressedForeground = UIManager.getColor("MenuItem.pressedForeground");
- }
-
- if (this.menuArrow == null || this.menuArrow instanceof UIResource) {
- this.menuArrow = UIManager.getIcon("MenuItem.arrowIcon");
- }
-
- if (((AbstractButton)var2).getSelectedIcon() == null || ((AbstractButton)var2).getSelectedIcon() instanceof UIResource) {
- ((AbstractButton)var2).setSelectedIcon(UIManager.getIcon("RadioButtonMenuItem.icon"));
- }
-
- }
-
- public void uninstallUI(JComponent var1) {
- JRadioButtonMenuItem var2 = (JRadioButtonMenuItem)var1;
- this.removeListeners(var1);
- LookAndFeel.uninstallBorder(var1);
- ((JMenuItem)var1).setBorderPainted(this.oldBorderPainted);
- if (this.menuArrow instanceof UIResource) {
- this.menuArrow = null;
- }
-
- if (this.checkIcon instanceof UIResource) {
- this.checkIcon = null;
- }
-
- if (((AbstractButton)var2).getSelectedIcon() instanceof UIResource) {
- ((AbstractButton)var2).setSelectedIcon((Icon)null);
- }
-
- }
-
- protected void initListeners(JComponent var1) {
- this.mouseListener = this.createMouseListener(var1);
- this.mouseMotionListener = this.createMouseMotionListener(var1);
- }
-
- protected void addListeners(JComponent var1) {
- ((Component)var1).addMouseListener(this.mouseListener);
- ((Component)var1).addMouseMotionListener(this.mouseMotionListener);
- }
-
- protected void removeListeners(JComponent var1) {
- ((Component)var1).removeMouseListener(this.mouseListener);
- ((Component)var1).removeMouseMotionListener(this.mouseMotionListener);
- }
-
- protected MouseListener createMouseListener(JComponent var1) {
- return new BasicMenuMouseListener();
- }
-
- protected MouseMotionListener createMouseMotionListener(JComponent var1) {
- return new BasicMenuMouseMotionListener();
- }
-
- public Insets getDefaultMargin(AbstractButton var1) {
- return new Insets(2, 2, 2, 2);
- }
-
- public Dimension getMinimumSize(JComponent var1) {
- return this.getPreferredSize(var1);
- }
-
- public Dimension getPreferredSize(JComponent var1) {
- return BasicGraphicsUtils.getPreferredMenuItemSize(var1, this.checkIcon, this.menuArrow, 4);
- }
-
- public Dimension getMaximumSize(JComponent var1) {
- return this.getPreferredSize(var1);
- }
-
- public void update(Graphics var1, JComponent var2) {
- this.paint(var1, var2);
- }
-
- public void paint(Graphics var1, JComponent var2) {
- BasicGraphicsUtils.paintMenuItem(var1, var2, ((JRadioButtonMenuItem)var2).getSelectedIcon(), this.menuArrow, pressedBackground, pressedForeground, 4);
- }
-
- public void processMouseEvent(JMenuItem var1, MouseEvent var2, MenuElement[] var3, MenuSelectionManager var4) {
- Point var5 = var2.getPoint();
- if (var5.x >= 0 && var5.x < ((JComponent)var1).getWidth() && var5.y >= 0 && var5.y < ((JComponent)var1).getHeight()) {
- if (((AWTEvent)var2).getID() == 502) {
- var4.clearSelectedPath();
- ((AbstractButton)var1).doClick(0);
- var1.setArmed(false);
- } else {
- var4.setSelectedPath(var3);
- }
- } else {
- if (((AbstractButton)var1).getModel().isArmed()) {
- MenuElement[] var6 = new MenuElement[var3.length - 1];
- int var7 = 0;
-
- for(int var8 = var3.length - 1; var7 < var8; ++var7) {
- var6[var7] = var3[var7];
- }
-
- var4.setSelectedPath(var6);
- }
-
- }
- }
- }
-