KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > synth > SynthCheckBoxMenuItemUI


1 /*
2  * @(#)SynthCheckBoxMenuItemUI.java 1.7 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.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 JavaDoc;
17
18
19 /**
20  * Synth's CheckBoxMenuItemUI.
21  *
22  * @version 1.7 12/19/03
23  * @author Leif Samuelsson
24  * @author Georges Saab
25  * @author David Karlton
26  * @author Arnaud Weber
27  */

28 class SynthCheckBoxMenuItemUI extends SynthMenuItemUI JavaDoc {
29
30     public static ComponentUI createUI(JComponent c) {
31         return new SynthCheckBoxMenuItemUI JavaDoc();
32     }
33
34     protected String JavaDoc 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 JavaDoc 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 JavaDoc 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