[gui][PATCH] Fixes/javadoc for JMenuItem
Olga Rodimina
rodimina@redhat.com
Wed Jun 9 23:25:00 GMT 2004
Hi,
I've documented, cleaned up and fixed menu related widgets.
I'll start with menu items. This patch fixes and documents JMenuItems.
It also adds suggested changes by Michael Koch to getPath() method in
BasicMenuItemUI. (Thanks!)
Patches containing fixes to JMenuBar, JMenu and JPopupMenu are coming
up.
I'll be committing this patch to java-gui-branch.
Olga.
-------------- next part --------------
? .snprj
? libjava.proj
? patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2660.2.147
diff -c -p -u -r1.2660.2.147 ChangeLog
--- ChangeLog 9 Jun 2004 21:02:35 -0000 1.2660.2.147
+++ ChangeLog 9 Jun 2004 22:33:23 -0000
@@ -1,3 +1,26 @@
+2004-06-09 Olga Rodimina <rodimina@redhat.com>
+
+ * javax/swing/AbstractButton.java
+ (AbstractButton): Use init() to initialize the button.
+ (init): New Method. Initializes AbstractButton.
+ * javax/swing/JMenuItem.java: Documented.
+ (JMenuItem): Reimplemented.
+ (init): Implemented.
+ (setEnabled): Changed to call super.setEnabled()
+ (processMouseEvent): Reimplemented.
+ (fireMenuKeyPressed): Implemented.
+ (fireMenuKeyReleased): Implemented.
+ (fireMenuKeyTyped): Implemented.
+ (menuSelectionChanged): disarm the model if the menu item was
+ deselected.
+ * javax/swing/plaf/basic/BasicMenuItemUI.java:Documented.
+ (getPath): Change to use ArrayList instead of Vector.
+ (getPreferredSize): Renamed variable.
+ (paintMenuItem): Paint margin area of menu item.
+ (MouseInputHandler.mouseEntered): Set selection in MenuSelectionManager.
+ (MouseInputHandler.mouseReleased): Check if mouse was pressed inside
+ menu item's bounds before clearing the selection.
+
2004-06-09 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkTextComponentPeer.java
Index: javax/swing/AbstractButton.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/AbstractButton.java,v
retrieving revision 1.5.2.6
diff -c -p -u -r1.5.2.6 AbstractButton.java
--- javax/swing/AbstractButton.java 9 Jun 2004 20:55:10 -0000 1.5.2.6
+++ javax/swing/AbstractButton.java 9 Jun 2004 22:33:24 -0000
@@ -475,28 +475,7 @@ public abstract class AbstractButton ext
*/
AbstractButton(String txt, Icon icon)
{
- text = txt;
- default_icon = icon;
- model = new DefaultButtonModel();
- actionListener = createActionListener();
- changeListener = createChangeListener();
- itemListener = createItemListener();
-
- model.addActionListener(actionListener);
- model.addChangeListener(changeListener);
- model.addItemListener(itemListener);
-
- hori_align = CENTER;
- hori_text_pos = TRAILING;
- vert_align = CENTER;
- vert_text_pos = CENTER;
- paint_border = true;
- content_area_filled = true;
-
- setAlignmentX(LEFT_ALIGNMENT);
- setAlignmentY(CENTER_ALIGNMENT);
-
- addFocusListener(new ButtonFocusListener());
+ init (txt, icon);
updateUI();
}
@@ -541,6 +520,32 @@ public abstract class AbstractButton ext
repaint();
}
+ protected void init(String text, Icon icon)
+ {
+ this.text = text;
+ default_icon = icon;
+ model = new DefaultButtonModel();
+ actionListener = createActionListener();
+ changeListener = createChangeListener();
+ itemListener = createItemListener();
+
+ model.addActionListener(actionListener);
+ model.addChangeListener(changeListener);
+ model.addItemListener(itemListener);
+
+ hori_align = CENTER;
+ hori_text_pos = TRAILING;
+ vert_align = CENTER;
+ vert_text_pos = CENTER;
+ paint_border = true;
+ content_area_filled = true;
+
+ setAlignmentX(LEFT_ALIGNMENT);
+ setAlignmentY(CENTER_ALIGNMENT);
+
+ addFocusListener(new ButtonFocusListener());
+ }
+
/**
* Get the action command string for this button's model.
*
Index: javax/swing/JMenuItem.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JMenuItem.java,v
retrieving revision 1.2.18.7
diff -c -p -u -r1.2.18.7 JMenuItem.java
--- javax/swing/JMenuItem.java 8 Jun 2004 09:28:42 -0000 1.2.18.7
+++ javax/swing/JMenuItem.java 9 Jun 2004 22:33:24 -0000
@@ -61,14 +61,26 @@ import javax.swing.plaf.MenuItemUI;
/**
- * DOCUMENT ME!
+ * <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.
+ * PropertyChangeEvents are fired when menuItems properties are modified;
+ * ChangeEvents are fired when menuItem's state changes and actionEvents are
+ * 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;
/**
@@ -76,44 +88,48 @@ public class JMenuItem extends AbstractB
*/
public JMenuItem()
{
- this(null, null);
+ super(null, null);
}
/**
- * Creates a new JMenuItem object.
+ * Creates a new JMenuItem with the given icon.
*
- * @param icon DOCUMENT ME!
+ * @param icon Icon that will be displayed on the menu item
*/
public JMenuItem(Icon icon)
{
- this(null, icon);
+ // FIXME: The requestedFocusEnabled property should
+ // be set to false, when only icon is set for menu item.
+ super(null, icon);
}
/**
- * Creates a new JMenuItem object.
+ * Creates a new JMenuItem with the given label.
*
- * @param text DOCUMENT ME!
+ * @param text label for the menu item
*/
public JMenuItem(String text)
{
- this(text, null);
+ super(text, null);
}
/**
- * Creates a new JMenuItem object.
+ * Creates a new JMenuItem associated with the specified action.
*
- * @param action DOCUMENT ME!
+ * @param action action for this menu item
*/
public JMenuItem(Action action)
{
- // TODO
+ super(null, null);
+ super.setAction(action);
}
/**
- * Creates a new JMenuItem object.
+ * Creates a new JMenuItem with specified text and icon.
+ * Text is displayed to the left of icon by default.
*
- * @param text DOCUMENT ME!
- * @param icon DOCUMENT ME!
+ * @param text label for this menu item
+ * @param icon icon that will be displayed on this menu item
*/
public JMenuItem(String text, Icon icon)
{
@@ -123,8 +139,10 @@ public class JMenuItem extends AbstractB
/**
* Creates a new JMenuItem object.
*
- * @param text DOCUMENT ME!
- * @param mnemonic DOCUMENT ME!
+ * @param text label for this menu item
+ * @param mnemonic - Single key that can be used with a
+ * look-and-feel meta key to activate this menu item. However
+ * menu item should be visible on the screen when mnemonic is used.
*/
public JMenuItem(String text, int mnemonic)
{
@@ -132,13 +150,17 @@ public class JMenuItem extends AbstractB
setMnemonic(mnemonic);
}
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
+ /**
+ * DOCUMENT ME!
+ *
+ * @param stream DOCUMENT ME!
+ *
+ * @throws IOException DOCUMENT ME!
+ * @throws ClassNotFoundException DOCUMENT ME!
+ */
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException
{
- // TODO
}
/**
@@ -150,24 +172,31 @@ public class JMenuItem extends AbstractB
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
- // TODO
}
/**
- * DOCUMENT ME!
+ * Initializes this menu item
*
- * @param text DOCUMENT ME!
- * @param icon DOCUMENT ME!
+ * @param text label for this menu item
+ * @param icon icon to be displayed for this menu item
*/
protected void init(String text, Icon icon)
{
- // TODO
+ super.init(text, icon);
+
+ // Initializes properties for this menu item, that are different
+ // from Abstract button properties.
+ paint_border = false;
+ paint_focus = false;
+ hori_align = JButton.LEFT;
+ hori_text_pos = JButton.LEFT;
}
/**
- * DOCUMENT ME!
+ * Set the "UI" property of the menu item, which is a look and feel class
+ * responsible for handling menuItem's input events and painting it.
*
- * @param ui DOCUMENT ME!
+ * @param ui The new "UI" property
*/
public void setUI(MenuItemUI ui)
{
@@ -175,7 +204,8 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * This method sets this menuItem's UI to the UIManager's default for the
+ * current look and feel.
*/
public void updateUI()
{
@@ -185,9 +215,10 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * This method returns a name to identify which look and feel class will be
+ * the UI delegate for the menuItem.
*
- * @return $returnType$ DOCUMENT ME!
+ * @return The Look and Feel classID. "MenuItemUI"
*/
public String getUIClassID()
{
@@ -195,9 +226,10 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Returns true if button's model is armed and false otherwise. The
+ * button model is armed if menu item has focus or it is selected.
*
- * @return $returnType$ DOCUMENT ME!
+ * @return $boolean$ true if button's model is armed and false otherwise
*/
public boolean isArmed()
{
@@ -205,7 +237,7 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Sets menuItem's "ARMED" property
*
* @param armed DOCUMENT ME!
*/
@@ -215,19 +247,20 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Enable or disable menu item. When menu item is disabled,
+ * its text and icon are grayed out if they exist.
*
- * @param enabled DOCUMENT ME!
+ * @param enabled if true enable menu item, and disable otherwise.
*/
public void setEnabled(boolean enabled)
{
- setEnabled(enabled);
+ super.setEnabled(enabled);
}
/**
- * DOCUMENT ME!
+ * Return accelerator for this menu item.
*
- * @return $returnType$ DOCUMENT ME!
+ * @return $KeyStroke$ accelerator for this menu item.
*/
public KeyStroke getAccelerator()
{
@@ -235,9 +268,9 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Sets accelerator for this menu item.
*
- * @param keystroke DOCUMENT ME!
+ * @param keystroke accelerator for this menu item.
*/
public void setAccelerator(KeyStroke keystroke)
{
@@ -245,9 +278,11 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Configures menu items' properties from properties of the specified action.
+ * This method overrides configurePropertiesFromAction from AbstractButton
+ * to also set accelerator property.
*
- * @param action DOCUMENT ME!
+ * @param action action to configure properties from
*/
protected void configurePropertiesFromAction(Action action)
{
@@ -260,11 +295,13 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Creates PropertyChangeListener to listen for the changes in action
+ * properties.
*
- * @param action DOCUMENT ME!
+ * @param action action to listen to for property changes
*
- * @return $returnType$ DOCUMENT ME!
+ * @return $PropertyChangeListener$ Listener that listens to changes in
+ * action properties.
*/
protected PropertyChangeListener createActionPropertyChangeListener(Action action)
{
@@ -279,11 +316,11 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Process mouse events forwarded from MenuSelectionManager.
*
- * @param event DOCUMENT ME!
- * @param path DOCUMENT ME!
- * @param manager DOCUMENT ME!
+ * @param event event forwarded from MenuSelectionManager
+ * @param path path to the menu element from which event was generated
+ * @param manager MenuSelectionManager for the current menu hierarchy
*/
public void processMouseEvent(MouseEvent event, MenuElement[] path,
MenuSelectionManager manager)
@@ -291,22 +328,15 @@ public class JMenuItem extends AbstractB
switch (event.getID())
{
case MouseEvent.MOUSE_CLICKED:
- doClick();
break;
case MouseEvent.MOUSE_ENTERED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
- ButtonModel model = item.getModel();
+ ButtonModel model = item.getModel();
if (item.isRolloverEnabled())
model.setRollover(true);
-
- if (model.isPressed()
- && (event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
- model.setArmed(true);
- else
- model.setArmed(false);
}
break;
case MouseEvent.MOUSE_EXITED:
@@ -316,7 +346,6 @@ public class JMenuItem extends AbstractB
ButtonModel model = item.getModel();
if (item.isRolloverEnabled())
model.setRollover(false);
- model.setArmed(false);
}
break;
case MouseEvent.MOUSE_PRESSED:
@@ -330,17 +359,6 @@ public class JMenuItem extends AbstractB
}
break;
case MouseEvent.MOUSE_RELEASED:
- if (event.getSource() instanceof JMenuItem)
- {
- JMenuItem item = (JMenuItem) event.getSource();
- ButtonModel model = item.getModel();
- if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
- {
- model.setPressed(false);
- model.setArmed(false);
- manager.clearSelectedPath();
- }
- }
break;
case MouseEvent.MOUSE_MOVED:
break;
@@ -374,9 +392,11 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * This method fires MenuDragMouseEvents to registered listeners.
+ * Different types of MenuDragMouseEvents are fired depending
+ * on the observed mouse event.
*
- * @param event DOCUMENT ME!
+ * @param event Mouse
*/
public void processMenuDragMouseEvent(MenuDragMouseEvent event)
{
@@ -398,7 +418,9 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * This method fires MenuKeyEvent to registered listeners.
+ * Different types of MenuKeyEvents are fired depending
+ * on the observed key event.
*
* @param event DOCUMENT ME!
*/
@@ -408,9 +430,9 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Fires MenuDragMouseEvent to all of the menuItem's MouseInputListeners.
*
- * @param event DOCUMENT ME!
+ * @param event The event signifying that mouse entered menuItem while it was dragged
*/
protected void fireMenuDragMouseEntered(MenuDragMouseEvent event)
{
@@ -421,9 +443,9 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Fires MenuDragMouseEvent to all of the menuItem's MouseInputListeners.
*
- * @param event DOCUMENT ME!
+ * @param event The event signifying that mouse has exited menu item, while it was dragged
*/
protected void fireMenuDragMouseExited(MenuDragMouseEvent event)
{
@@ -434,9 +456,9 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Fires MenuDragMouseEvent to all of the menuItem's MouseInputListeners.
*
- * @param event DOCUMENT ME!
+ * @param event The event signifying that mouse is being dragged over the menuItem
*/
protected void fireMenuDragMouseDragged(MenuDragMouseEvent event)
{
@@ -447,9 +469,9 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * This method fires a MenuDragMouseEvent to all the MenuItem's MouseInputListeners.
*
- * @param event DOCUMENT ME!
+ * @param event The event signifying that mouse was released while it was dragged over the menuItem
*/
protected void fireMenuDragMouseReleased(MenuDragMouseEvent event)
{
@@ -460,50 +482,70 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
*
- * @param event DOCUMENT ME!
+ * @param event The event signifying that key associated with this menu was pressed
*/
protected void fireMenuKeyPressed(MenuKeyEvent event)
{
- // TODO
+ EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);
+
+ for (int i = 0; i < ll.length; i++)
+ ((MenuKeyListener) ll[i]).menuKeyPressed(event);
}
/**
- * DOCUMENT ME!
+ * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
*
- * @param event DOCUMENT ME!
+ * @param event The event signifying that key associated with this menu was released
*/
protected void fireMenuKeyReleased(MenuKeyEvent event)
{
- // TODO
+ EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);
+
+ for (int i = 0; i < ll.length; i++)
+ ((MenuKeyListener) ll[i]).menuKeyTyped(event);
}
/**
- * DOCUMENT ME!
+ * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
*
- * @param event DOCUMENT ME!
+ * @param event The event signifying that key associated with this menu was typed.
+ * The key is typed when it was pressed and then released
*/
protected void fireMenuKeyTyped(MenuKeyEvent event)
{
- // TODO
+ EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);
+
+ for (int i = 0; i < ll.length; i++)
+ ((MenuKeyListener) ll[i]).menuKeyTyped(event);
}
/**
- * DOCUMENT ME!
+ * Method of the MenuElement interface.
+ * This method is invoked by MenuSelectionManager when selection of
+ * this menu item has changed. If this menu item was selected then
+ * arm it's model, and disarm the model otherwise. The menu item
+ * is considered to be selected, and thus highlighted when its model
+ * is armed.
*
- * @param changed DOCUMENT ME!
+ * @param changed indicates selection status of this menu item. If changed is
+ * true then menu item is selected and deselected otherwise.
*/
public void menuSelectionChanged(boolean changed)
{
if (changed)
model.setArmed(true);
+ else
+ model.setArmed(false);
}
/**
- * DOCUMENT ME!
+ * Method of the MenuElement interface.
*
- * @return $returnType$ DOCUMENT ME!
+ * @return $MenuElement[]$ Returns array of sub-components for this menu
+ * item. By default menuItem doesn't have any subcomponents and so
+ * empty array is returned instead.
*/
public MenuElement[] getSubElements()
{
@@ -511,9 +553,10 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Returns reference to the component that will paint this menu item.
*
- * @return $returnType$ DOCUMENT ME!
+ * @return $Component$ Component that will paint this menu item.
+ * Simply returns reference to this menu item.
*/
public Component getComponent()
{
@@ -521,9 +564,11 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Adds a MenuDragMouseListener to this menu item. When mouse
+ * is dragged over the menu item the MenuDragMouseEvents will be
+ * fired, and these listeners will be called.
*
- * @param listener DOCUMENT ME!
+ * @param listener The new listener to add
*/
public void addMenuDragMouseListener(MenuDragMouseListener listener)
{
@@ -531,9 +576,9 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Removes a MenuDragMouseListener from the menuItem's listener list.
*
- * @param listener DOCUMENT ME!
+ * @param listener The listener to remove
*/
public void removeMenuDragMouseListener(MenuDragMouseListener listener)
{
@@ -541,9 +586,10 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Adds an MenuKeyListener to this menu item. This listener will be
+ * invoked when MenuKeyEvents will be fired by this menu item.
*
- * @param listener DOCUMENT ME!
+ * @param listener The new listener to add
*/
public void addMenuKeyListener(MenuKeyListener listener)
{
@@ -551,9 +597,9 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Removes an MenuKeyListener from the menuItem's listener list.
*
- * @param listener DOCUMENT ME!
+ * @param listener The listener to remove
*/
public void removeMenuKeyListener(MenuKeyListener listener)
{
@@ -561,9 +607,10 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * A string that describes this JMenuItem. Normally only used
+ * for debugging.
*
- * @return $returnType$ DOCUMENT ME!
+ * @return A string describing this JMenuItem
*/
protected String paramString()
{
@@ -573,7 +620,7 @@ public class JMenuItem extends AbstractB
/**
* DOCUMENT ME!
*
- * @return $returnType$ DOCUMENT ME!
+ * @return DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
@@ -583,9 +630,6 @@ public class JMenuItem extends AbstractB
return accessibleContext;
}
- /**
- * DOCUMENT ME!
- */
protected class AccessibleJMenuItem extends AccessibleAbstractButton
implements ChangeListener
{
@@ -596,23 +640,13 @@ public class JMenuItem extends AbstractB
*/
AccessibleJMenuItem()
{
+ //super(component);
}
- /**
- * DOCUMENT ME!
- *
- * @param event DOCUMENT ME!
- */
public void stateChanged(ChangeEvent event)
{
- // TODO
}
- /**
- * DOCUMENT ME!
- *
- * @return $returnType$ DOCUMENT ME!
- */
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.MENU_ITEM;
Index: javax/swing/plaf/basic/BasicMenuItemUI.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicMenuItemUI.java,v
retrieving revision 1.1.2.11
diff -c -p -u -r1.1.2.11 BasicMenuItemUI.java
--- javax/swing/plaf/basic/BasicMenuItemUI.java 3 Jun 2004 14:21:53 -0000 1.1.2.11
+++ javax/swing/plaf/basic/BasicMenuItemUI.java 9 Jun 2004 22:33:24 -0000
@@ -1,5 +1,5 @@
-/* BasicMenuItemUI.java
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+/* BasicMenuItemUI.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,20 +35,26 @@ this exception to your version of the li
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
+import java.awt.AWTKeyStroke;
+import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
+import java.awt.Insets;
import java.awt.Rectangle;
+import java.awt.Stroke;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
import java.util.Vector;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
@@ -65,6 +71,8 @@ import javax.swing.MenuSelectionManager;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
import javax.swing.event.MenuDragMouseListener;
import javax.swing.event.MenuKeyEvent;
@@ -75,7 +83,7 @@ import javax.swing.plaf.MenuItemUI;
/**
- * DOCUMENT ME!
+ * UI Delegate for JMenuItem.
*/
public class BasicMenuItemUI extends MenuItemUI
{
@@ -156,6 +164,10 @@ public class BasicMenuItemUI extends Men
* String that separates description of the modifiers and the key
*/
private String acceleratorDelimiter;
+
+ /**
+ * PropertyChangeListener to listen for property changes in the menu item
+ */
private PropertyChangeListener propertyChangeListener;
/**
@@ -163,6 +175,9 @@ public class BasicMenuItemUI extends Men
*/
private int defaultAcceleratorLabelGap = 4;
+ /**
+ * Creates a new BasicMenuItemUI object.
+ */
public BasicMenuItemUI()
{
mouseInputListener = createMouseInputListener(menuItem);
@@ -171,17 +186,25 @@ public class BasicMenuItemUI extends Men
propertyChangeListener = new PropertyChangeHandler();
}
+ /**
+ * Create MenuDragMouseListener to listen for mouse dragged events.
+ *
+ * @param c menu item to listen to
+ *
+ * @return The MenuDragMouseListener
+ */
protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
{
return new MenuDragMouseHandler();
}
/**
- * DOCUMENT ME!
+ * Creates MenuKeyListener to listen to key events occuring when menu item
+ * is visible on the screen.
*
- * @param c DOCUMENT ME!
+ * @param c menu item to listen to
*
- * @return $returnType$ DOCUMENT ME!
+ * @return The MenuKeyListener
*/
protected MenuKeyListener createMenuKeyListener(JComponent c)
{
@@ -189,11 +212,11 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Handles mouse input events occuring for this menu item
*
- * @param c DOCUMENT ME!
+ * @param c menu item to listen to
*
- * @return $returnType$ DOCUMENT ME!
+ * @return The MouseInputListener
*/
protected MouseInputListener createMouseInputListener(JComponent c)
{
@@ -201,11 +224,12 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Factory method to create a BasicMenuItemUI for the given {@link
+ * JComponent}, which should be a {@link JMenuItem}.
*
- * @param c DOCUMENT ME!
+ * @param c The {@link JComponent} a UI is being created for.
*
- * @return $returnType$ DOCUMENT ME!
+ * @return A BasicMenuItemUI for the {@link JComponent}.
*/
public static ComponentUI createUI(JComponent c)
{
@@ -213,9 +237,9 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Programatically clicks menu item.
*
- * @param msm DOCUMENT ME!
+ * @param msm MenuSelectionManager for the menu hierarchy
*/
protected void doClick(MenuSelectionManager msm)
{
@@ -224,11 +248,11 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Returns maximum size for the specified menu item
*
- * @param c DOCUMENT ME!
+ * @param c component for which to get maximum size
*
- * @return $returnType$ DOCUMENT ME!
+ * @return Maximum size for the specified menu item.
*/
public Dimension getMaximumSize(JComponent c)
{
@@ -236,11 +260,11 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Returns minimum size for the specified menu item
*
- * @param c DOCUMENT ME!
+ * @param c component for which to get minimum size
*
- * @return $returnType$ DOCUMENT ME!
+ * @return Minimum size for the specified menu item.
*/
public Dimension getMinimumSize(JComponent c)
{
@@ -248,17 +272,18 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Returns path to this menu item.
*
- * @return $returnType$ DOCUMENT ME!
+ * @return $MenuElement[]$ Returns array of menu elements
+ * that constitute a path to this menu item.
*/
public MenuElement[] getPath()
{
- Vector path = new Vector();
+ ArrayList path = new ArrayList();
Component c = menuItem;
while (c instanceof MenuElement)
{
- path.add(c);
+ path.add(0, (MenuElement) c);
if (c instanceof JPopupMenu)
c = ((JPopupMenu) c).getInvoker();
@@ -266,54 +291,51 @@ public class BasicMenuItemUI extends Men
c = c.getParent();
}
- // convert from vector to array
MenuElement[] pathArray = new MenuElement[path.size()];
- for (int i = 0; i < path.size(); i++)
- pathArray[i] = (MenuElement) path.get(path.size() - i - 1);
-
+ path.toArray(pathArray);
return pathArray;
}
/**
- * DOCUMENT ME!
+ * Returns preferred size for the given menu item.
*
- * @param c DOCUMENT ME!
- * @param checkIcon DOCUMENT ME!
- * @param arrowIcon DOCUMENT ME!
- * @param defaultTextIconGap DOCUMENT ME!
+ * @param c menu item for which to get preferred size
+ * @param checkIcon chech icon displayed in the given menu item
+ * @param arrowIcon arrow icon displayed in the given menu item
+ * @param defaultTextIconGap space between icon and text in the given menuItem
*
- * @return $returnType$ DOCUMENT ME!
+ * @return $Dimension$ preferred size for the given menu item
*/
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon,
Icon arrowIcon,
int defaultTextIconGap)
{
- // TODO
+ // FIXME: Need to implement.
return null;
}
/**
- * DOCUMENT ME!
+ * Returns preferred size of the given component
*
- * @param c DOCUMENT ME!
+ * @param c component for which to return preferred size
*
- * @return $returnType$ DOCUMENT ME!
+ * @return $Dimension$ preferred size for the given component
*/
public Dimension getPreferredSize(JComponent c)
{
- AbstractButton b = (AbstractButton) c;
- Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b,
+ JMenuItem m = (JMenuItem) c;
+ Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m,
defaultTextIconGap);
// if menu item has accelerator then take accelerator's size into account
// when calculating preferred size.
- KeyStroke accelerator = ((JMenuItem) c).getAccelerator();
+ KeyStroke accelerator = m.getAccelerator();
Rectangle rect;
if (accelerator != null)
{
rect = getAcceleratorRect(accelerator,
- b.getToolkit().getFontMetrics(acceleratorFont));
+ m.getToolkit().getFontMetrics(acceleratorFont));
// add width of accelerator's text
d.width = d.width + rect.width + defaultAcceleratorLabelGap;
@@ -349,22 +371,22 @@ public class BasicMenuItemUI extends Men
*/
protected String getPropertyPrefix()
{
- // TODO
return null;
}
/**
- * DOCUMENT ME!
+ * This method installs the components for this {@link JMenuItem}.
*
- * @param menuItem DOCUMENT ME!
+ * @param menuItem The {@link JMenuItem} to install components for.
*/
protected void installComponents(JMenuItem menuItem)
{
- // TODO
+ // FIXME: Need to implement
}
/**
- * DOCUMENT ME!
+ * This method installs the defaults that are defined in the Basic look and
+ * feel for this {@link JMenuItem}.
*/
protected void installDefaults()
{
@@ -376,7 +398,6 @@ public class BasicMenuItemUI extends Men
menuItem.setForeground(defaults.getColor("MenuItem.foreground"));
menuItem.setMargin(defaults.getInsets("MenuItem.margin"));
menuItem.setOpaque(true);
-
acceleratorFont = defaults.getFont("MenuItem.acceleratorFont");
acceleratorForeground = defaults.getColor("MenuItem.acceleratorForeground");
acceleratorSelectionForeground = defaults.getColor("MenuItem.acceleratorSelectionForeground");
@@ -386,15 +407,15 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This method installs the keyboard actions for this {@link JMenuItem}.
*/
protected void installKeyboardActions()
{
- // TODO
+ // FIXME: Need to implement
}
/**
- * DOCUMENT ME!
+ * This method installs the listeners for the {@link JMenuItem}.
*/
protected void installListeners()
{
@@ -405,9 +426,11 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Installs and initializes all fields for this UI delegate. Any properties
+ * of the UI that need to be initialized and/or set to defaults will be
+ * done now. It will also install any listeners necessary.
*
- * @param c DOCUMENT ME!
+ * @param c The {@link JComponent} that is having this UI installed.
*/
public void installUI(JComponent c)
{
@@ -418,10 +441,10 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Paints given menu item using specified graphics context
*
- * @param g DOCUMENT ME!
- * @param c DOCUMENT ME!
+ * @param g The graphics context used to paint this menu item
+ * @param c Menu Item to paint
*/
public void paint(Graphics g, JComponent c)
{
@@ -430,11 +453,11 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Paints background of the menu item
*
- * @param g DOCUMENT ME!
- * @param menuItem DOCUMENT ME!
- * @param bgColor DOCUMENT ME!
+ * @param g The graphics context used to paint this menu item
+ * @param menuItem menu item to paint
+ * @param bgColor Background color to use when painting menu item
*/
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
{
@@ -446,21 +469,22 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Paints specified menu item
*
- * @param g DOCUMENT ME!
- * @param c DOCUMENT ME!
- * @param checkIcon DOCUMENT ME!
- * @param arrowIcon DOCUMENT ME!
- * @param background DOCUMENT ME!
- * @param foreground DOCUMENT ME!
- * @param defaultTextIconGap DOCUMENT ME!
+ * @param g The graphics context used to paint this menu item
+ * @param c menu item to paint
+ * @param checkIcon check icon to use when painting menu item
+ * @param arrowIcon arrow icon to use when painting menu item
+ * @param background Background color of the menu item
+ * @param foreground Foreground color of the menu item
+ * @param defaultTextIconGap space to use between icon and
+ * text when painting menu item
*/
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon,
Icon arrowIcon, Color background,
Color foreground, int defaultTextIconGap)
{
- AbstractButton b = (AbstractButton) c;
+ JMenuItem m = (JMenuItem) c;
Rectangle tr = new Rectangle(); // text rectangle
Rectangle ir = new Rectangle(); // icon rectangle
Rectangle vr = new Rectangle(); // view rectangle
@@ -468,41 +492,53 @@ public class BasicMenuItemUI extends Men
Rectangle ar = new Rectangle(); // accelerator rectangle
Rectangle cr = new Rectangle(); // checkIcon rectangle
- int vertAlign = b.getVerticalAlignment();
- int horAlign = b.getHorizontalAlignment();
- int vertTextPos = b.getVerticalTextPosition();
- int horTextPos = b.getHorizontalTextPosition();
+ int vertAlign = m.getVerticalAlignment();
+ int horAlign = m.getHorizontalAlignment();
+ int vertTextPos = m.getVerticalTextPosition();
+ int horTextPos = m.getHorizontalTextPosition();
- Font f = c.getFont();
+ Font f = m.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics(f);
- SwingUtilities.calculateInnerArea(b, br);
- SwingUtilities.calculateInsetArea(br, b.getMargin(), vr);
- paintBackground(g, (JMenuItem) c, c.getBackground());
-
- if ((b.getModel().isArmed() && b.getModel().isPressed()))
+ SwingUtilities.calculateInnerArea(m, br);
+ SwingUtilities.calculateInsetArea(br, m.getInsets(), vr);
+ paintBackground(g, m, m.getBackground());
+
+ /* MenuItems insets are equal to menuItems margin, space between text and
+ menuItems border. We need to paint insets region as well. */
+ Insets insets = m.getInsets();
+ br.x -= insets.left;
+ br.y -= insets.top;
+ br.width += insets.right + insets.left;
+ br.height += insets.top + insets.bottom;
+
+ /* Menu item is considered to be highlighted when it is selected.
+ It is considered to be selected if menu item is inside some menu
+ and is armed or if it is both armed and pressed */
+ if (m.getModel().isArmed()
+ && (m.getParent() instanceof MenuElement || m.getModel().isPressed()))
{
- if (((AbstractButton) b).isContentAreaFilled())
+ if (m.isContentAreaFilled())
{
- g.setColor(b.getBackground().darker());
+ g.setColor(m.getBackground().darker());
g.fillRect(br.x, br.y, br.width, br.height);
}
}
else
{
- if (((AbstractButton) b).isContentAreaFilled())
+ if (m.isContentAreaFilled())
{
- g.setColor(b.getBackground());
+ g.setColor(m.getBackground());
g.fillRect(br.x, br.y, br.width, br.height);
}
}
if (checkIcon != null)
{
- SwingUtilities.layoutCompoundLabel(c, fm, null, checkIcon, vertAlign,
+ SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign,
horAlign, vertTextPos, horTextPos,
vr, cr, tr, defaultTextIconGap);
- checkIcon.paintIcon(c, g, cr.x, cr.y);
+ checkIcon.paintIcon(m, g, cr.x, cr.y);
// We need to calculate position of the menu text and position of
// user menu icon if there exists one relative to the check icon.
@@ -518,25 +554,25 @@ public class BasicMenuItemUI extends Men
int width = arrowIcon.getIconWidth();
int height = arrowIcon.getIconHeight();
- arrowIcon.paintIcon(c, g, vr.width - width + defaultTextIconGap,
+ arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap,
vr.y + 2);
}
}
// paint text and user menu icon if it exists
- SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), b.getIcon(),
+ SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), m.getIcon(),
vertAlign, horAlign, vertTextPos,
horTextPos, vr, ir, tr,
defaultTextIconGap);
- paintText(g, (JMenuItem) c, tr, b.getText());
+ paintText(g, m, tr, m.getText());
// paint icon
// FIXME: should paint different icon at different button state's.
// i.e disabled icon when button is disabled.. etc.
/*
- Icon i = b.getIcon();
+ Icon i = m.getIcon();
if (i != null)
{
int x = ir.x;
@@ -548,30 +584,31 @@ public class BasicMenuItemUI extends Men
// paint accelerator
String acceleratorText = "";
- if (((JMenuItem) c).getAccelerator() != null)
+ if (m.getAccelerator() != null)
{
- acceleratorText = getAcceleratorText(((JMenuItem) c).getAccelerator());
+ acceleratorText = getAcceleratorText(m.getAccelerator());
fm = g.getFontMetrics(acceleratorFont);
ar.width = fm.stringWidth(acceleratorText);
ar.x = br.width - ar.width;
vr.x = br.width - ar.width;
- SwingUtilities.layoutCompoundLabel(c, fm, acceleratorText, null,
+ SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null,
vertAlign, horAlign, vertTextPos,
horTextPos, vr, ir, ar,
defaultTextIconGap);
- paintAccelerator(g, (JMenuItem) c, ar, acceleratorText);
+ paintAccelerator(g, m, ar, acceleratorText);
}
}
/**
- * DOCUMENT ME!
+ * Paints label for the given menu item
*
- * @param g DOCUMENT ME!
- * @param menuItem DOCUMENT ME!
- * @param textRect DOCUMENT ME!
- * @param text DOCUMENT ME!
+ * @param g The graphics context used to paint this menu item
+ * @param menuItem menu item for which to draw its label
+ * @param textRect rectangle specifiying position of the text relative to
+ * the given menu item
+ * @param text label of the menu item
*/
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect,
String text)
@@ -586,17 +623,18 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This method uninstalls the components for this {@link JMenuItem}.
*
- * @param menuItem DOCUMENT ME!
+ * @param menuItem The {@link JMenuItem} to uninstall components for.
*/
protected void uninstallComponents(JMenuItem menuItem)
{
- // TODO
+ // FIXME: need to implement
}
/**
- * DOCUMENT ME!
+ * This method uninstalls the defaults and sets any objects created during
+ * install to null
*/
protected void uninstallDefaults()
{
@@ -619,15 +657,15 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Uninstalls any keyboard actions.
*/
protected void uninstallKeyboardActions()
{
- // TODO
+ // FIXME: need to implement
}
/**
- * DOCUMENT ME!
+ * Unregisters all the listeners that this UI delegate was using.
*/
protected void uninstallListeners()
{
@@ -638,9 +676,11 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Performs the opposite of installUI. Any properties or resources that need
+ * to be cleaned up will be done now. It will also uninstall any listeners
+ * it has. In addition, any properties of this UI will be nulled.
*
- * @param c DOCUMENT ME!
+ * @param c The {@link JComponent} that is having this UI uninstalled.
*/
public void uninstallUI(JComponent c)
{
@@ -650,10 +690,10 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This method calls paint.
*
- * @param g DOCUMENT ME!
- * @param c DOCUMENT ME!
+ * @param g The graphics context used to paint this menu item
+ * @param c The menu item to paint
*/
public void update(Graphics g, JComponent c)
{
@@ -661,11 +701,11 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Return text representation of the specified accelerator
*
- * @param accelerator DOCUMENT ME!
+ * @param accelerator Accelerator for which to return string representation
*
- * @return $returnType$ DOCUMENT ME!
+ * @return $String$ Text representation of the given accelerator
*/
private String getAcceleratorText(KeyStroke accelerator)
{
@@ -686,12 +726,12 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Calculates and return rectange in which accelerator should be displayed
*
- * @param accelerator DOCUMENT ME!
- * @param fm DOCUMENT ME!
+ * @param accelerator accelerator for which to return the display rectangle
+ * @param fm The font metrics used to measure the text
*
- * @return $returnType$ DOCUMENT ME!
+ * @return $Rectangle$ reactangle which will be used to display accelerator
*/
private Rectangle getAcceleratorRect(KeyStroke accelerator, FontMetrics fm)
{
@@ -701,12 +741,13 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Paints accelerator inside menu item
*
- * @param g DOCUMENT ME!
- * @param menuItem DOCUMENT ME!
- * @param acceleratorRect DOCUMENT ME!
- * @param acceleratorText DOCUMENT ME!
+ * @param g The graphics context used to paint the border
+ * @param menuItem Menu item for which to draw accelerator
+ * @param acceleratorRect rectangle representing position
+ * of the accelerator relative to the menu item
+ * @param acceleratorText accelerator's text
*/
private void paintAccelerator(Graphics g, JMenuItem menuItem,
Rectangle acceleratorRect,
@@ -720,7 +761,10 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This class handles mouse events occuring inside the menu item.
+ * Most of the events are forwarded for processing to MenuSelectionManager
+ * of the current menu hierarchy.
+ *
*/
protected class MouseInputHandler implements MouseInputListener
{
@@ -732,9 +776,10 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This method is called when mouse is clicked on the menu item.
+ * It forwards this event to MenuSelectionManager.
*
- * @param e DOCUMENT ME!
+ * @param e A {@link MouseEvent}.
*/
public void mouseClicked(MouseEvent e)
{
@@ -743,9 +788,10 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This method is called when mouse is dragged inside the menu item.
+ * It forwards this event to MenuSelectionManager.
*
- * @param e DOCUMENT ME!
+ * @param e A {@link MouseEvent}.
*/
public void mouseDragged(MouseEvent e)
{
@@ -754,20 +800,29 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This method is called when mouse enters menu item.
+ * When this happens menu item is considered to be selected and selection path
+ * in MenuSelectionManager is set. This event is also forwarded to MenuSelection
+ * Manager for further processing.
*
- * @param e DOCUMENT ME!
+ * @param e A {@link MouseEvent}.
*/
public void mouseEntered(MouseEvent e)
{
- MenuSelectionManager manager = MenuSelectionManager.defaultManager();
- manager.processMouseEvent(e);
+ Component source = (Component) e.getSource();
+ if (source.getParent() instanceof MenuElement)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.setSelectedPath(getPath());
+ manager.processMouseEvent(e);
+ }
}
/**
- * DOCUMENT ME!
+ * This method is called when mouse exits menu item. The event is
+ * forwarded to MenuSelectionManager for processing.
*
- * @param e DOCUMENT ME!
+ * @param e A {@link MouseEvent}.
*/
public void mouseExited(MouseEvent e)
{
@@ -776,9 +831,10 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This method is called when mouse is inside the menu item.
+ * This event is forwarder to MenuSelectionManager for further processing.
*
- * @param e DOCUMENT ME!
+ * @param e A {@link MouseEvent}.
*/
public void mouseMoved(MouseEvent e)
{
@@ -787,9 +843,10 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This method is called when mouse is pressed. This event is forwarded to
+ * MenuSelectionManager for further processing.
*
- * @param e DOCUMENT ME!
+ * @param e A {@link MouseEvent}.
*/
public void mousePressed(MouseEvent e)
{
@@ -798,57 +855,64 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This method is called when mouse is released. If the mouse is released
+ * inside this menuItem, then this menu item is considered to be chosen and
+ * the menu hierarchy should be closed.
*
- * @param e DOCUMENT ME!
+ * @param e A {@link MouseEvent}.
*/
public void mouseReleased(MouseEvent e)
{
- // FIXME: Should check if the mouse released while mouse cursor
- // was indeed over the menu item. If this wasn't the case we probably
- // should sent this event to MenuSelectionManager.
- MenuSelectionManager manager = MenuSelectionManager.defaultManager();
- manager.clearSelectedPath();
- menuItem.doClick(0);
+ Rectangle size = menuItem.getBounds(); //this.getParent().getSize();
+ if (e.getX() > 0 && e.getX() < size.width && e.getY() > 0
+ && e.getY() < size.height)
+ {
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.clearSelectedPath();
+ menuItem.doClick(0);
+ }
}
}
/**
- * DOCUMENT ME!
+ * This class handles mouse dragged events.
*/
protected class MenuDragMouseHandler implements MenuDragMouseListener
{
/**
- * DOCUMENT ME!
+ * Tbis method is invoked when mouse is dragged over the menu item.
*
- * @param e DOCUMENT ME!
+ * @param e The MenuDragMouseEvent
*/
public void menuDragMouseDragged(MenuDragMouseEvent e)
{
}
/**
- * DOCUMENT ME!
+ * Tbis method is invoked when mouse enters the menu item while it is
+ * being dragged.
*
- * @param e DOCUMENT ME!
+ * @param e The MenuDragMouseEvent
*/
public void menuDragMouseEntered(MenuDragMouseEvent e)
{
}
/**
- * DOCUMENT ME!
+ * Tbis method is invoked when mouse exits the menu item while
+ * it is being dragged
*
- * @param e DOCUMENT ME!
+ * @param e The MenuDragMouseEvent
*/
public void menuDragMouseExited(MenuDragMouseEvent e)
{
}
/**
- * DOCUMENT ME!
+ * Tbis method is invoked when mouse was dragged and released
+ * inside the menu item.
*
- * @param e DOCUMENT ME!
+ * @param e The MenuDragMouseEvent
*/
public void menuDragMouseReleased(MenuDragMouseEvent e)
{
@@ -856,32 +920,34 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * This class handles key events occuring when menu item is visible on the
+ * screen.
*/
protected class MenuKeyHandler implements MenuKeyListener
{
/**
- * DOCUMENT ME!
+ * This method is invoked when key has been pressed
*
- * @param e DOCUMENT ME!
+ * @param e A {@link MenuKeyEvent}.
*/
public void menuKeyPressed(MenuKeyEvent e)
{
}
/**
- * DOCUMENT ME!
+ * This method is invoked when key has been pressed
*
- * @param e DOCUMENT ME!
+ * @param e A {@link MenuKeyEvent}.
*/
public void menuKeyReleased(MenuKeyEvent e)
{
}
/**
- * DOCUMENT ME!
+ * This method is invoked when key has been typed
+ * It handles the mnemonic key for the menu item.
*
- * @param e DOCUMENT ME!
+ * @param e A {@link MenuKeyEvent}.
*/
public void menuKeyTyped(MenuKeyEvent e)
{
@@ -889,14 +955,15 @@ public class BasicMenuItemUI extends Men
}
/**
- * DOCUMENT ME!
+ * Helper class that listens for changes to the properties of the {@link
+ * JMenuItem}.
*/
protected class PropertyChangeHandler implements PropertyChangeListener
{
/**
- * DOCUMENT ME!
+ * This method is called when one of the menu item's properties change.
*
- * @param evt DOCUMENT ME!
+ * @param evt A {@link PropertyChangeEvent}.
*/
public void propertyChange(PropertyChangeEvent evt)
{
More information about the Java-patches
mailing list