Index: javax/swing/JMenu.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JMenu.java,v
retrieving revision 1.3.8.15
diff -u -r1.3.8.15 JMenu.java
--- javax/swing/JMenu.java 27 Dec 2004 11:25:01 -0000 1.3.8.15
+++ javax/swing/JMenu.java 28 Jan 2005 10:42:41 -0000
@@ -1,5 +1,5 @@
/* JMenu.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -77,9 +77,6 @@
{
private static final long serialVersionUID = 4227225638931828014L;
- /** name for the UI delegate for this menu. */
- private static final String uiClassID = "MenuUI";
-
/** A Popup menu associated with this menu, which pops up when menu is selected */
private JPopupMenu popupMenu = new JPopupMenu();
@@ -107,30 +104,32 @@
}
/**
- * Creates a new JMenu with the spicified label
+ * Creates a new JMenu
with the specified label.
*
* @param text label for this menu
*/
public JMenu(String text)
{
super(text);
+ popupMenu.setInvoker(this);
}
/**
- * Creates a new JMenu object
+ * Creates a new JMenu
object.
*
- * @param action Action that is used to create menu item tha will be
+ * @param action Action that is used to create menu item tha will be
* added to the menu.
*/
public JMenu(Action action)
{
super(action);
createActionChangeListener(this);
+ popupMenu.setInvoker(this);
}
/**
- * Creates a new JMenu with specified label and an option
- * for this menu to be tear-off menu
+ * Creates a new JMenu
with specified label and an option
+ * for this menu to be tear-off menu.
*
* @param text label for this menu
* @param tearoff true if this menu should be tear-off and false otherwise
@@ -312,7 +311,7 @@
*/
public String getUIClassID()
{
- return uiClassID;
+ return "MenuUI";
}
/**
@@ -388,8 +387,8 @@
/**
* Checks if PopupMenu associated with this menu is visible
*
- * @return true if the popup associated with this menu is currently visible on the screen and
- * false otherwise.
+ * @return true if the popup associated with this menu is currently visible
+ * on the screen and false otherwise.
*/
public boolean isPopupMenuVisible()
{
@@ -528,15 +527,15 @@
}
/**
- * Returns number of items in the menu
+ * Returns number of items in the menu including separators.
*
* @return number of items in the menu
+ *
+ * @see #getMenuComponentCount()
*/
public int getItemCount()
{
- // returns the number of items on
- // the menu, including separators.
- return getComponents().length;
+ return getMenuComponentCount();
}
/**
@@ -592,10 +591,7 @@
*/
public boolean isTopLevelMenu()
{
- if (getParent() instanceof JMenuBar)
- return true;
- else
- return false;
+ return getParent() instanceof JMenuBar;
}
/**
Index: javax/swing/JMenuItem.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JMenuItem.java,v
retrieving revision 1.2.18.17
diff -u -r1.2.18.17 JMenuItem.java
--- javax/swing/JMenuItem.java 10 Nov 2004 07:19:48 -0000 1.2.18.17
+++ javax/swing/JMenuItem.java 28 Jan 2005 10:42:41 -0000
@@ -1,5 +1,5 @@
/* JMenuItem.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,9 +60,7 @@
import javax.swing.event.MenuKeyListener;
import javax.swing.plaf.MenuItemUI;
-
/**
- *
* JMenuItem represents element in the menu. It inherits most of * its functionality from AbstractButton, however its behavior somewhat * varies from it. JMenuItem fire different kinds of events. @@ -71,16 +69,12 @@ * fired when menu item is selected. In addition to this events menuItem also * fire MenuDragMouseEvent and MenuKeyEvents when mouse is dragged over * the menu item or associated key with menu item is invoked respectively. - *
*/ public class JMenuItem extends AbstractButton implements Accessible, MenuElement { private static final long serialVersionUID = -1681004643499461044L; - /** name for the UI delegate for this menuItem. */ - private static final String uiClassID = "MenuItemUI"; - /** Combination of keyboard keys that can be used to activate this menu item */ private KeyStroke accelerator; @@ -212,7 +206,7 @@ */ public String getUIClassID() { - return uiClassID; + return "MenuItemUI"; } /** Index: javax/swing/JPopupMenu.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/javax/swing/JPopupMenu.java,v retrieving revision 1.3.8.17 diff -u -r1.3.8.17 JPopupMenu.java --- javax/swing/JPopupMenu.java 26 Jan 2005 23:33:32 -0000 1.3.8.17 +++ javax/swing/JPopupMenu.java 28 Jan 2005 10:42:41 -0000 @@ -53,6 +53,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.util.ArrayList; import java.util.EventListener; import javax.accessibility.Accessible; @@ -92,9 +93,6 @@ { private static final long serialVersionUID = -8336996630009646009L; - /** name for the UI delegate for this menuItem. */ - private static final String uiClassID = "PopupMenuUI"; - /* indicates if popup's menu border should be painted*/ private boolean borderPainted = true; @@ -144,11 +142,7 @@ */ public JPopupMenu() { - updateUI(); - - lightWeightPopupEnabled = DefaultLightWeightPopupEnabled; - selectionModel = new DefaultSingleSelectionModel(); - super.setVisible(false); + this(null); } /** @@ -158,7 +152,11 @@ */ public JPopupMenu(String label) { + lightWeightPopupEnabled = getDefaultLightWeightPopupEnabled(); setLabel(label); + setSelectionModel(new DefaultSingleSelectionModel()); + super.setVisible(false); + updateUI(); } private void readObject(ObjectInputStream stream) @@ -821,19 +819,22 @@ } /** - * Return subcomonents of this popup menu. + * Return subcomonents of this popup menu. This method returns only + * components that implement theMenuElement
interface.
*
- * @return Array containing menuItem's of belonging to this popup menu.
+ * @return array of menu items belonging to this popup menu
*/
public MenuElement[] getSubElements()
{
Component[] items = getComponents();
- MenuElement[] subElements = new MenuElement[items.length];
+ ArrayList subElements = new ArrayList();
for (int i = 0; i < items.length; i++)
- subElements[i] = (MenuElement) items[i];
+ if (items[i] instanceof MenuElement)
+ subElements.add(items[i]);
- return subElements;
+ return (MenuElement[])
+ subElements.toArray(new MenuElement[subElements.size()]);
}
/**
@@ -1020,14 +1021,6 @@
this.setBounds(x, y, width, height);
this.show();
}
-
- /**
- * Hides JWindow with menu item's from the screen.
- */
- public void hide()
- {
- super.hide();
- }
}
/**