KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)SynthRadioButtonMenuItemUI.java 1.5 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 import javax.swing.*;
11 import java.awt.*;
12 import java.awt.event.*;
13 import javax.swing.plaf.*;
14 import javax.swing.border.*;
15
16 /**
17  * Synth's RadioButtonMenuItemUI.
18  *
19  * @version 1.5, 12/19/03
20  * @author Georges Saab
21  * @author David Karlton
22  */

23 class SynthRadioButtonMenuItemUI extends SynthMenuItemUI JavaDoc {
24     public static ComponentUI createUI(JComponent b) {
25         return new SynthRadioButtonMenuItemUI JavaDoc();
26     }
27
28     protected String JavaDoc 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 JavaDoc 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 JavaDoc 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