KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > basic > BasicCheckBoxMenuItemUI


1 /*
2  * @(#)BasicCheckBoxMenuItemUI.java 1.53 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

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 JavaDoc;
16
17
18 /**
19  * BasicCheckboxMenuItem implementation
20  *
21  * @version 1.53 12/19/03
22  * @author Georges Saab
23  * @author David Karlton
24  * @author Arnaud Weber
25  */

26 public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI JavaDoc {
27
28     public static ComponentUI createUI(JComponent c) {
29         return new BasicCheckBoxMenuItemUI JavaDoc();
30     }
31
32     protected String JavaDoc 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