2 Copyright (C) 2002, 2004 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. */
40 import java
.awt
.Component
;
41 import java
.awt
.Dimension
;
42 import java
.awt
.Graphics
;
43 import java
.awt
.Insets
;
44 import java
.awt
.event
.KeyEvent
;
45 import java
.awt
.event
.MouseEvent
;
46 import java
.beans
.PropertyChangeListener
;
47 import java
.io
.IOException
;
48 import java
.io
.ObjectInputStream
;
49 import java
.io
.ObjectOutputStream
;
50 import javax
.accessibility
.Accessible
;
51 import javax
.accessibility
.AccessibleContext
;
52 import javax
.accessibility
.AccessibleRole
;
53 import javax
.swing
.event
.PopupMenuListener
;
54 import javax
.swing
.plaf
.PopupMenuUI
;
58 * @author Andrew Selkirk
61 public class JPopupMenu
extends JComponent
implements Accessible
, MenuElement
64 //-------------------------------------------------------------
65 // Classes ----------------------------------------------------
66 //-------------------------------------------------------------
71 public static class Separator
extends JSeparator
{
73 //-------------------------------------------------------------
74 // Initialization ---------------------------------------------
75 //-------------------------------------------------------------
78 * Constructor Separator
85 //-------------------------------------------------------------
86 // Methods ----------------------------------------------------
87 //-------------------------------------------------------------
93 public String
getUIClassID() {
101 * AccessibleJPopupMenu
103 protected class AccessibleJPopupMenu
extends AccessibleJComponent
{
105 //-------------------------------------------------------------
106 // Variables --------------------------------------------------
107 //-------------------------------------------------------------
110 //-------------------------------------------------------------
111 // Initialization ---------------------------------------------
112 //-------------------------------------------------------------
115 * Constructor AccessibleJPopupMenu
116 * @param component TODO
118 protected AccessibleJPopupMenu(JPopupMenu component
) {
121 } // AccessibleJPopupMenu()
124 //-------------------------------------------------------------
125 // Methods ----------------------------------------------------
126 //-------------------------------------------------------------
130 * @returns AccessibleRole
132 public AccessibleRole
getAccessibleRole() {
133 return AccessibleRole
.POPUP_MENU
;
134 } // getAccessibleRole()
137 } // AccessibleJPopupMenu
140 //-------------------------------------------------------------
141 // Variables --------------------------------------------------
142 //-------------------------------------------------------------
147 private static final String uiClassID
= "PopupMenuUI";
152 transient Component invoker
;
157 private int desiredLocationX
;
162 private int desiredLocationY
;
167 private String label
;
172 private boolean paintBorder
;
177 private Insets margin
;
180 * defaultLWPopupEnabledKey
182 private static final Object defaultLWPopupEnabledKey
= null; // TODO
185 * lightWeightPopupEnabled
187 private boolean lightWeightPopupEnabled
;
192 private SingleSelectionModel selectionModel
;
195 //-------------------------------------------------------------
196 // Initialization ---------------------------------------------
197 //-------------------------------------------------------------
200 * Constructor JPopupMenu
202 public JPopupMenu() {
207 * Constructor JPopupMenu
210 public JPopupMenu(String label
) {
215 //-------------------------------------------------------------
216 // Methods ----------------------------------------------------
217 //-------------------------------------------------------------
222 * @exception IOException TODO
223 * @exception ClassNotFoundException TODO
225 private void readObject(ObjectInputStream stream
)
226 throws IOException
, ClassNotFoundException
{
233 * @exception IOException TODO
235 private void writeObject(ObjectOutputStream stream
) throws IOException
{
244 public JMenuItem
add(JMenuItem item
) {
253 public JMenuItem
add(String text
) {
262 public JMenuItem
add(Action action
) {
270 public void remove(int index
) {
279 public void insert(Action action
, int index
) {
285 * @param component TODO
288 public void insert(Component component
, int index
) {
294 * @param graphics TODO
296 protected void paintBorder(Graphics graphics
) {
301 * getDefaultLightWeightPopupEnabled
304 public static boolean getDefaultLightWeightPopupEnabled() {
305 return false; // TODO
306 } // getDefaultLightWeightPopupEnabled()
309 * setDefaultLightWeightPopupEnabled
310 * @param enabled TODO
312 public static void setDefaultLightWeightPopupEnabled(boolean enabled
) {
314 } // setDefaultLightWeightPopupEnabled()
318 * @returns PopupMenuUI
320 public PopupMenuUI
getUI() {
321 return (PopupMenuUI
) ui
;
328 public void setUI(PopupMenuUI ui
) {
336 public void updateUI() {
337 setUI((PopupMenuUI
) UIManager
.get(this));
345 public String
getUIClassID() {
351 * @returns SingleSelectionModel
353 public SingleSelectionModel
getSelectionModel() {
355 } // getSelectionModel()
361 public void setSelectionModel(SingleSelectionModel model
) {
363 } // setSelectionModel()
366 * createActionComponent
370 protected JMenuItem
createActionComponent(Action action
) {
372 } // createActionComponent()
375 * createActionChangeListener
377 * @returns PropertyChangeListener
379 protected PropertyChangeListener
createActionChangeListener(JMenuItem item
) {
381 } // createActionChangeListener()
384 * isLightWeightPopupEnabled
387 public boolean isLightWeightPopupEnabled() {
388 return false; // TODO
389 } // isLightWeightPopupEnabled()
392 * setLightWeightPopupEnabled
393 * @param enabled TODO
395 public void setLightWeightPopupEnabled(boolean enabled
) {
397 } // setLightWeightPopupEnabled()
403 public String
getLabel() {
411 public void setLabel(String label
) {
418 public void addSeparator() {
423 * addPopupMenuListener
424 * @param listener TODO
426 public void addPopupMenuListener(PopupMenuListener listener
) {
428 } // addPopupMenuListener()
431 * removePopupMenuListener
432 * @param listener TODO
434 public void removePopupMenuListener(PopupMenuListener listener
) {
436 } // removePopupMenuListener()
439 * firePopupMenuWillBecomeVisible
441 protected void firePopupMenuWillBecomeVisible() {
443 } // firePopupMenuWillBecomeVisible()
446 * firePopupMenuWillBecomeInvisible
448 protected void firePopupMenuWillBecomeInvisible() {
450 } // firePopupMenuWillBecomeInvisible()
453 * firePopupMenuCanceled
455 protected void firePopupMenuCanceled() {
457 } // firePopupMenuCanceled()
470 public boolean isVisible() {
471 return false; // TODO
476 * @param visible TODO
478 public void setVisible(boolean visible
) {
487 public void setLocation(int x
, int y
) {
495 private boolean isPopupMenu() {
496 return false; // TODO
503 public Component
getInvoker() {
509 * @param component TODO
511 public void setInvoker(Component component
) {
517 * @param component TODO
521 public void show(Component component
, int x
, int y
) {
527 * @returns JPopupMenu
529 JPopupMenu
getRootPopupMenu() {
531 } // getRootPopupMenu()
534 * getComponentAtIndex
538 public Component
getComponentAtIndex(int index
) {
540 } // getComponentAtIndex()
544 * @param component TODO
547 public int getComponentIndex(Component component
) {
549 } // getComponentIndex()
555 public void setPopupSize(Dimension size
) {
564 public void setPopupSize(int x
, int y
) {
570 * @param selected TODO
572 public void setSelected(Component selected
) {
580 public boolean isBorderPainted() {
581 return false; // TODO
582 } // isBorderPainted()
586 * @param painted TODO
588 public void setBorderPainted(boolean painted
) {
590 } // setBorderPainted()
596 public Insets
getMargin() {
604 protected String
paramString() {
612 * @param manager TODO
614 public void processMouseEvent(MouseEvent event
, MenuElement
[] path
,
615 MenuSelectionManager manager
) {
617 } // processMouseEvent()
623 * @param manager TODO
625 public void processKeyEvent(KeyEvent event
, MenuElement
[] path
,
626 MenuSelectionManager manager
) {
628 } // processKeyEvent()
631 * menuSelectionChanged
632 * @param changed TODO
634 public void menuSelectionChanged(boolean changed
) {
636 } // menuSelectionChanged()
640 * @returns MenuElement[]
642 public MenuElement
[] getSubElements() {
644 } // getSubElements()
650 public Component
getComponent() {
659 public boolean isPopupTrigger(MouseEvent event
) {
660 return false; // TODO
661 } // isPopupTrigger()
664 * getAccessibleContext
665 * @returns AccessibleContext
667 public AccessibleContext
getAccessibleContext() {
668 if (accessibleContext
== null) {
669 accessibleContext
= new AccessibleJPopupMenu(this);
671 return accessibleContext
;
672 } // getAccessibleContext()