2 Copyright (C) 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
41 import java
.awt
.Component
;
42 import java
.awt
.event
.KeyEvent
;
43 import java
.awt
.event
.MouseEvent
;
44 import java
.beans
.PropertyChangeListener
;
45 import java
.io
.IOException
;
46 import java
.io
.ObjectInputStream
;
47 import java
.io
.ObjectOutputStream
;
48 import javax
.accessibility
.Accessible
;
49 import javax
.accessibility
.AccessibleContext
;
50 import javax
.accessibility
.AccessibleRole
;
51 import javax
.swing
.event
.ChangeEvent
;
52 import javax
.swing
.event
.ChangeListener
;
53 import javax
.swing
.event
.MenuDragMouseEvent
;
54 import javax
.swing
.event
.MenuDragMouseListener
;
55 import javax
.swing
.event
.MenuKeyEvent
;
56 import javax
.swing
.event
.MenuKeyListener
;
57 import javax
.swing
.plaf
.MenuItemUI
;
61 * @author Andrew Selkirk
64 public class JMenuItem
extends AbstractButton
implements Accessible
, MenuElement
{
66 //-------------------------------------------------------------
67 // Classes ----------------------------------------------------
68 //-------------------------------------------------------------
73 protected class AccessibleJMenuItem
extends AccessibleAbstractButton
74 implements ChangeListener
{
76 //-------------------------------------------------------------
77 // Variables --------------------------------------------------
78 //-------------------------------------------------------------
81 //-------------------------------------------------------------
82 // Initialization ---------------------------------------------
83 //-------------------------------------------------------------
86 * Constructor AccessibleJMenuItem
87 * @param component TODO
89 AccessibleJMenuItem(JMenuItem component
) {
92 } // AccessibleJMenuItem()
95 //-------------------------------------------------------------
96 // Methods ----------------------------------------------------
97 //-------------------------------------------------------------
103 public void stateChanged(ChangeEvent event
) {
109 * @returns AccessibleRole
111 public AccessibleRole
getAccessibleRole() {
112 return AccessibleRole
.MENU_ITEM
;
113 } // getAccessibleRole()
116 } // AccessibleJMenuItem
119 //-------------------------------------------------------------
120 // Variables --------------------------------------------------
121 //-------------------------------------------------------------
126 private static final String uiClassID
= "MenuItemUI";
131 private KeyStroke accelerator
;
134 //-------------------------------------------------------------
135 // Initialization ---------------------------------------------
136 //-------------------------------------------------------------
139 * Constructor JMenuItem
146 * Constructor JMenuItem
149 public JMenuItem(Icon icon
) {
154 * Constructor JMenuItem
157 public JMenuItem(String text
) {
162 * Constructor JMenuItem
165 public JMenuItem(Action action
) {
170 * Constructor JMenuItem
174 public JMenuItem(String text
, Icon icon
) {
179 * Constructor JMenuItem
181 * @param mnemonic TODO
183 public JMenuItem(String text
, int mnemonic
) {
188 //-------------------------------------------------------------
189 // Methods ----------------------------------------------------
190 //-------------------------------------------------------------
195 * @exception IOException TODO
196 * @exception ClassNotFoundException TODO
198 private void readObject(ObjectInputStream stream
)
199 throws IOException
, ClassNotFoundException
{
206 * @exception IOException TODO
208 private void writeObject(ObjectOutputStream stream
) throws IOException
{
217 protected void init(String text
, Icon icon
) {
225 public void setUI(MenuItemUI ui
) {
233 public void updateUI() {
234 setUI((MenuItemUI
) UIManager
.get(this));
242 public String
getUIClassID() {
250 public boolean isArmed() {
251 return false; // TODO
258 public void setArmed(boolean armed
) {
264 * @param enabled TODO
266 public void setEnabled(boolean enabled
) {
274 public KeyStroke
getAccelerator() {
276 } // getAccelerator()
280 * @param keystroke TODO
282 public void setAccelerator(KeyStroke keystroke
) {
284 } // setAccelerator()
287 * configurePropertiesFromAction
290 protected void configurePropertiesFromAction(Action action
) {
292 } // configurePropertiesFromAction()
295 * createActionPropertyChangeListener
297 * @returns PropertyChangeListener
299 protected PropertyChangeListener
createActionPropertyChangeListener(Action action
) {
301 } // createActionPropertyChangeListener()
307 * @param manager TODO
309 public void processMouseEvent(MouseEvent event
, MenuElement
[] path
,
310 MenuSelectionManager manager
) {
312 } // processMouseEvent()
318 * @param manager TODO
320 public void processKeyEvent(KeyEvent event
, MenuElement
[] path
,
321 MenuSelectionManager manager
) {
323 } // processKeyEvent()
326 * processMenuDragMouseEvent
329 public void processMenuDragMouseEvent(MenuDragMouseEvent event
) {
331 } // processMenuDragMouseEvent()
334 * processMenuKeyEvent
337 public void processMenuKeyEvent(MenuKeyEvent event
) {
339 } // processMenuKeyEvent()
342 * fireMenuDragMouseEntered
345 protected void fireMenuDragMouseEntered(MenuDragMouseEvent event
) {
347 } // fireMenuDragMouseEntered()
350 * fireMenuDragMouseExited
353 protected void fireMenuDragMouseExited(MenuDragMouseEvent event
) {
355 } // fireMenuDragMouseExited()
358 * fireMenuDragMouseDragged
361 protected void fireMenuDragMouseDragged(MenuDragMouseEvent event
) {
363 } // fireMenuDragMouseDragged()
366 * fireMenuDragMouseReleased
369 protected void fireMenuDragMouseReleased(MenuDragMouseEvent event
) {
371 } // fireMenuDragMouseReleased()
377 protected void fireMenuKeyPressed(MenuKeyEvent event
) {
379 } // fireMenuKeyPressed()
382 * fireMenuKeyReleased
385 protected void fireMenuKeyReleased(MenuKeyEvent event
) {
387 } // fireMenuKeyReleased()
393 protected void fireMenuKeyTyped(MenuKeyEvent event
) {
395 } // fireMenuKeyTyped()
398 * menuSelectionChanged
399 * @param changed TODO
401 public void menuSelectionChanged(boolean changed
) {
403 } // menuSelectionChanged()
407 * @returns MenuElement[]
409 public MenuElement
[] getSubElements() {
411 } // getSubElements()
417 public Component
getComponent() {
422 * addMenuDragMouseListener
423 * @param listener TODO
425 public void addMenuDragMouseListener(MenuDragMouseListener listener
) {
427 } // addMenuDragMouseListener()
430 * removeMenuDragMouseListener
431 * @param listener TODO
433 public void removeMenuDragMouseListener(MenuDragMouseListener listener
) {
435 } // removeMenuDragMouseListener()
439 * @param listener TODO
441 public void addMenuKeyListener(MenuKeyListener listener
) {
443 } // addMenuKeyListener()
446 * removeMenuKeyListener
447 * @param listener TODO
449 public void removeMenuKeyListener(MenuKeyListener listener
) {
451 } // removeMenuKeyListener()
457 protected String
paramString() {
462 * getAccessibleContext
463 * @returns AccessibleContext
465 public AccessibleContext
getAccessibleContext() {
466 if (accessibleContext
== null) {
467 accessibleContext
= new AccessibleJMenuItem(this);
469 return accessibleContext
;
470 } // getAccessibleContext()