1 7 8 package javax.swing.plaf.synth; 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 class SynthRadioButtonMenuItemUI extends SynthMenuItemUI { 24 public static ComponentUI createUI(JComponent b) { 25 return new SynthRadioButtonMenuItemUI (); 26 } 27 28 protected String getPropertyPrefix() { 29 return "RadioButtonMenuItem"; 30 } 31 32 public void processMouseEvent(JMenuItem item,MouseEvent e,MenuElement path[],MenuSelectionManager manager) { 33 Point p = e.getPoint(); 34 if(p.x >= 0 && p.x < item.getWidth() && 35 p.y >= 0 && p.y < item.getHeight()) { 36 if(e.getID() == MouseEvent.MOUSE_RELEASED) { 37 manager.clearSelectedPath(); 38 item.doClick(0); 39 item.setArmed(false); 40 } else 41 manager.setSelectedPath(path); 42 } else if(item.getModel().isArmed()) { 43 MenuElement newPath[] = new MenuElement[path.length-1]; 44 int i,c; 45 for(i=0,c=path.length-1;i<c;i++) 46 newPath[i] = path[i]; 47 manager.setSelectedPath(newPath); 48 } 49 } 50 51 void paintBackground(SynthContext context, Graphics g, JComponent c) { 52 context.getPainter().paintRadioButtonMenuItemBackground(context, g, 0, 53 0, c.getWidth(), c.getHeight()); 54 } 55 56 public void paintBorder(SynthContext context, Graphics g, int x, 57 int y, int w, int h) { 58 context.getPainter().paintRadioButtonMenuItemBorder(context, g, x, 59 y, w, h); 60 } 61 } 62 | Popular Tags |