1 30 31 package com.jgoodies.looks.common; 32 33 import java.awt.Point ; 34 import java.awt.event.MouseEvent ; 35 36 import javax.swing.JComponent ; 37 import javax.swing.JMenuItem ; 38 import javax.swing.MenuElement ; 39 import javax.swing.MenuSelectionManager ; 40 import javax.swing.plaf.ComponentUI ; 41 42 43 49 public class ExtBasicRadioButtonMenuItemUI extends ExtBasicMenuItemUI { 50 51 protected String getPropertyPrefix() { return "RadioButtonMenuItem"; } 52 53 54 public static ComponentUI createUI(JComponent b) { 55 return new ExtBasicRadioButtonMenuItemUI(); 56 } 57 58 59 protected boolean iconBorderEnabled() { return true; } 61 62 63 public void processMouseEvent(JMenuItem item, MouseEvent e, 64 MenuElement path[], MenuSelectionManager manager) { 65 Point p = e.getPoint(); 66 if (p.x >= 0 && p.x < item.getWidth() && 67 p.y >= 0 && p.y < item.getHeight()) { 68 if (e.getID() == MouseEvent.MOUSE_RELEASED) { 69 manager.clearSelectedPath(); 70 item.doClick(0); 71 item.setArmed(false); 72 } else 73 manager.setSelectedPath(path); 74 } else if (item.getModel().isArmed()) { 75 MenuElement newPath[] = new MenuElement [path.length - 1]; 76 int i, c; 77 for (i = 0, c = path.length - 1; i < c; i++) 78 newPath[i] = path[i]; 79 manager.setSelectedPath(newPath); 80 } 81 } 82 83 } | Popular Tags |