1 7 8 package javax.swing.plaf.basic; 9 10 import javax.swing.*; 11 import java.awt.*; 12 import java.awt.event.*; 13 import javax.swing.plaf.*; 14 import javax.swing.border.*; 15 16 23 public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI 24 { 25 public static ComponentUI createUI(JComponent b) { 26 return new BasicRadioButtonMenuItemUI (); 27 } 28 29 protected String getPropertyPrefix() { 30 return "RadioButtonMenuItem"; 31 } 32 33 public void processMouseEvent(JMenuItem item,MouseEvent e,MenuElement path[],MenuSelectionManager manager) { 34 Point p = e.getPoint(); 35 if(p.x >= 0 && p.x < item.getWidth() && 36 p.y >= 0 && p.y < item.getHeight()) { 37 if(e.getID() == MouseEvent.MOUSE_RELEASED) { 38 manager.clearSelectedPath(); 39 item.doClick(0); 40 item.setArmed(false); 41 } else 42 manager.setSelectedPath(path); 43 } else if(item.getModel().isArmed()) { 44 MenuElement newPath[] = new MenuElement[path.length-1]; 45 int i,c; 46 for(i=0,c=path.length-1;i<c;i++) 47 newPath[i] = path[i]; 48 manager.setSelectedPath(newPath); 49 } 50 } 51 } 52 53 54 55 56 57 58 59 60 | Popular Tags |