KickJava   Java API By Example, From Geeks To Geeks.

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


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

23 public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI JavaDoc
24 {
25     public static ComponentUI createUI(JComponent b) {
26         return new BasicRadioButtonMenuItemUI JavaDoc();
27     }
28
29     protected String JavaDoc getPropertyPrefix() {
30     return "RadioButtonMenuItem";
31     }
32     
33     public void processMouseEvent(JMenuItem item,MouseEvent e,MenuElement path[],MenuSelectionManager manager) {
34         Point p = e.getPoint();
35         if(p.x >= 0 && p.x < item.getWidth() &&
36            p.y >= 0 && p.y < item.getHeight()) {
37             if(e.getID() == MouseEvent.MOUSE_RELEASED) {
38                 manager.clearSelectedPath();
39                 item.doClick(0);
40                 item.setArmed(false);
41             } else
42                 manager.setSelectedPath(path);
43         } else if(item.getModel().isArmed()) {
44             MenuElement newPath[] = new MenuElement[path.length-1];
45             int i,c;
46             for(i=0,c=path.length-1;i<c;i++)
47                 newPath[i] = path[i];
48             manager.setSelectedPath(newPath);
49         }
50     }
51 }
52
53
54
55
56
57
58
59
60
Popular Tags