1 7 8 package javax.swing.plaf.synth; 9 10 11 import java.awt.*; 12 import java.awt.event.*; 13 import javax.swing.*; 14 import javax.swing.plaf.*; 15 import javax.swing.border.*; 16 import java.io.Serializable ; 17 18 19 28 class SynthCheckBoxMenuItemUI extends SynthMenuItemUI { 29 30 public static ComponentUI createUI(JComponent c) { 31 return new SynthCheckBoxMenuItemUI (); 32 } 33 34 protected String getPropertyPrefix() { 35 return "CheckBoxMenuItem"; 36 } 37 38 public void processMouseEvent(JMenuItem item, MouseEvent e, 39 MenuElement path[], MenuSelectionManager manager) { 40 Point p = e.getPoint(); 41 if (p.x >= 0 && p.x < item.getWidth() && p.y >= 0 && p.y < item.getHeight()) { 42 if (e.getID() == MouseEvent.MOUSE_RELEASED) { 43 manager.clearSelectedPath(); 44 item.doClick(0); 45 } else { 46 manager.setSelectedPath(path); 47 } 48 } else if (item.getModel().isArmed()) { 49 int c = path.length - 1; 50 MenuElement newPath[] = new MenuElement[c]; 51 for (int i = 0; i < c; i++) { 52 newPath[i] = path[i]; 53 } 54 manager.setSelectedPath(newPath); 55 } 56 } 57 58 void paintBackground(SynthContext context, Graphics g, JComponent c) { 59 context.getPainter().paintCheckBoxMenuItemBackground(context, g, 0, 0, 60 c.getWidth(), c.getHeight()); 61 } 62 63 public void paintBorder(SynthContext context, Graphics g, int x, 64 int y, int w, int h) { 65 context.getPainter().paintCheckBoxMenuItemBorder(context, g, x, y, w, h); 66 } 67 } 68 | Popular Tags |