aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2005-01-28 10:46:13 +0000
committerMichael Koch <konqueror@gmx.de>2005-01-28 10:46:13 +0000
commit6273a0210f38876f1dec6f2759713eead3e79be1 (patch)
tree9b68420807ed14a40805a99b80e7da51ea628426
parent1aa2ef68d480b87c72cc04ff7ac51b4474f2f591 (diff)
2005-01-28 Michael Koch <konqueror@gmx.de>
* javax/swing/JMenu.java (uiClassID): Removed. (JMenu): Set invoker on popup menu. (getUIClassID): Return id directly. (getItemCount): Simply return getMenuComponentCount(). Fixed javadoc. (isTopLevelMenu): Simplified. * javax/swing/JMenuItem.java (uiClassID): Removed. (getUIClassID): Return id directly. * javax/swing/JPopupMenu.java (uiClassID): Removed. (JPopupMenu): Always initialize correctly. (getSubElements): Only return components implementing MenuElement interface. (HeavyWeightPopup.hide): Removed. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/java-gui-branch@94367 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libjava/ChangeLog19
-rw-r--r--libjava/javax/swing/JMenu.java36
-rw-r--r--libjava/javax/swing/JMenuItem.java10
-rw-r--r--libjava/javax/swing/JPopupMenu.java35
4 files changed, 51 insertions, 49 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index ddd3434b35f..217c52a92a3 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,24 @@
2005-01-28 Michael Koch <konqueror@gmx.de>
+ * javax/swing/JMenu.java
+ (uiClassID): Removed.
+ (JMenu): Set invoker on popup menu.
+ (getUIClassID): Return id directly.
+ (getItemCount): Simply return getMenuComponentCount().
+ Fixed javadoc.
+ (isTopLevelMenu): Simplified.
+ * javax/swing/JMenuItem.java
+ (uiClassID): Removed.
+ (getUIClassID): Return id directly.
+ * javax/swing/JPopupMenu.java
+ (uiClassID): Removed.
+ (JPopupMenu): Always initialize correctly.
+ (getSubElements): Only return components implementing MenuElement
+ interface.
+ (HeavyWeightPopup.hide): Removed.
+
+2005-01-28 Michael Koch <konqueror@gmx.de>
+
* java/awt/image/ReplicateScaleFilter.java
(replicatePixels): Made private.
* javax/swing/colorchooser/DefaultRGBChooserPanel.java
diff --git a/libjava/javax/swing/JMenu.java b/libjava/javax/swing/JMenu.java
index b96ed604020..9a9289f0bc1 100644
--- a/libjava/javax/swing/JMenu.java
+++ b/libjava/javax/swing/JMenu.java
@@ -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 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
{
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 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
}
/**
- * Creates a new JMenu with the spicified label
+ * Creates a new <code>JMenu</code> 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 <code>JMenu</code> 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 <code>JMenu</code> 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 class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public String getUIClassID()
{
- return uiClassID;
+ return "MenuUI";
}
/**
@@ -388,8 +387,8 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
/**
* 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 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
}
/**
- * 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 class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public boolean isTopLevelMenu()
{
- if (getParent() instanceof JMenuBar)
- return true;
- else
- return false;
+ return getParent() instanceof JMenuBar;
}
/**
diff --git a/libjava/javax/swing/JMenuItem.java b/libjava/javax/swing/JMenuItem.java
index 06d29adbdd7..aec4178d1a3 100644
--- a/libjava/javax/swing/JMenuItem.java
+++ b/libjava/javax/swing/JMenuItem.java
@@ -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.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.plaf.MenuItemUI;
-
/**
- * <p>
* 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 @@ import javax.swing.plaf.MenuItemUI;
* 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.
- * </p>
*/
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 class JMenuItem extends AbstractButton implements Accessible,
*/
public String getUIClassID()
{
- return uiClassID;
+ return "MenuItemUI";
}
/**
diff --git a/libjava/javax/swing/JPopupMenu.java b/libjava/javax/swing/JPopupMenu.java
index 704e8319e63..b5b72db9df8 100644
--- a/libjava/javax/swing/JPopupMenu.java
+++ b/libjava/javax/swing/JPopupMenu.java
@@ -53,6 +53,7 @@ import java.beans.PropertyChangeListener;
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 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
{
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 class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public JPopupMenu()
{
- updateUI();
-
- lightWeightPopupEnabled = DefaultLightWeightPopupEnabled;
- selectionModel = new DefaultSingleSelectionModel();
- super.setVisible(false);
+ this(null);
}
/**
@@ -158,7 +152,11 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public JPopupMenu(String label)
{
+ lightWeightPopupEnabled = getDefaultLightWeightPopupEnabled();
setLabel(label);
+ setSelectionModel(new DefaultSingleSelectionModel());
+ super.setVisible(false);
+ updateUI();
}
private void readObject(ObjectInputStream stream)
@@ -821,19 +819,22 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
}
/**
- * Return subcomonents of this popup menu.
+ * Return subcomonents of this popup menu. This method returns only
+ * components that implement the <code>MenuElement</code> 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 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
this.setBounds(x, y, width, height);
this.show();
}
-
- /**
- * Hides JWindow with menu item's from the screen.
- */
- public void hide()
- {
- super.hide();
- }
}
/**