1 /*
2 * JScroll - the scrollable desktop pane for Java.
3 * Copyright (C) 2003 Tom Tessier
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 */
20
21 package org.jscroll.widgets;
22
23 import javax.swing.*;
24
25 import java.awt.event.*;
26
27
28 /***
29 * This class creates a base radio button menu item. ActionListener, mnemonic,
30 * keyboard shortcut, and title are set via the constructor.
31 * <BR><BR>
32 * A {@link org.jscroll.widgets.JScrollInternalFrame JScrollInternalFrame}
33 * object may optionally be associated with an instance of this class.
34 *
35 * @author <a href="mailto:tessier@gabinternet.com">Tom Tessier</a>
36 * @version 1.0 11-Aug-2001
37 */
38 public class RootRadioButtonMenuItem extends JRadioButtonMenuItem
39 implements FrameAccessorInterface {
40 private JScrollInternalFrame associatedFrame;
41
42 /***
43 * creates the RootRadioButtonMenuItem with an associated frame. Used for
44 * radio menu items that are associated with an internal frame.
45 *
46 * @param listener the action listener to assign
47 * @param itemTitle the title of the item
48 * @param mnemonic the mnemonic used to access the menu
49 * @param shortcut the keyboard shortcut used to access the menu.
50 * -1 indicates no shortcut.
51 * @param selected <code>boolean</code> that indicates whether
52 * the menu item is selected or not
53 * @param associatedFrame the JScrollInternalFrame associated with the menu item
54 */
55 public RootRadioButtonMenuItem(ActionListener listener, String itemTitle,
56 int mnemonic, int shortcut, boolean selected,
57 JScrollInternalFrame associatedFrame) {
58 this(listener, itemTitle, mnemonic, shortcut, selected);
59 this.associatedFrame = associatedFrame;
60 }
61
62 /***
63 * creates the RootRadioButtonMenuItem without an associated frame. Used
64 * for generic radio button menu items.
65 *
66 * @param listener the action listener to assign
67 * @param itemTitle the title of the item
68 * @param mnemonic the mnemonic used to access the menu
69 * @param shortcut the keyboard shortcut used to access the menu.
70 * -1 indicates no shortcut.
71 * @param selected <code>boolean</code> that indicates whether
72 * the menu item is selected or not
73 */
74 public RootRadioButtonMenuItem(ActionListener listener, String itemTitle,
75 int mnemonic, int shortcut, boolean selected) {
76 super(itemTitle, selected);
77 setMnemonic(mnemonic);
78
79 // set the alt-Shortcut accelerator
80 if (shortcut != -1) {
81 setAccelerator(KeyStroke.getKeyStroke(shortcut, ActionEvent.ALT_MASK));
82 }
83
84 setActionCommand(itemTitle + "Radio");
85 addActionListener(listener);
86 }
87
88 /***
89 * sets the associated frame
90 *
91 * @param associatedFrame the JScrollInternalFrame object to associate with
92 * the menu item
93 */
94 public void setAssociatedFrame(JScrollInternalFrame associatedFrame) {
95 this.associatedFrame = associatedFrame;
96 }
97
98 /***
99 * returns the associated frame
100 *
101 * @return the JScrollInternalFrame object associated with this menu item
102 */
103 public JScrollInternalFrame getAssociatedFrame() {
104 return associatedFrame;
105 }
106 }
This page was automatically generated by Maven