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