[gui][PATCH] Javadocs for menu components
Olga Rodimina
rodimina@redhat.com
Wed Jul 14 06:08:00 GMT 2004
Hi,
I fixed javadocs for menu related components and made few other small
fixes.
I will be committing this patch to java-gui-branch.
Olga.
-------------- next part --------------
? .snprj
? libjava.proj
? package-list
? patch
? pathc
? resources
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2660.2.265
diff -c -p -u -r1.2660.2.265 ChangeLog
--- ChangeLog 13 Jul 2004 15:20:48 -0000 1.2660.2.265
+++ ChangeLog 13 Jul 2004 15:34:07 -0000
@@ -1,3 +1,27 @@
+2004-07-13 Olga Rodimina <rodimina@redhat.com>
+
+ * javax/swing/JCheckBoxMenuItem.java: Fixed Javadocs.
+ * javax/swing/JMenu.java: Likewise.
+ * javax/swing/JMenuBar.java: Likewise.
+ (MARGIN_CHANGED_PROPERTY): New property.
+ (setMargin): Implemented.
+ * javax/swing/JMenuItem.java: Fixed javadocs.
+ (LABEL_CHANGED_PROPERTY): New property.
+ (add): changed to use createActionComponent.
+ (createActionComponent): Implemented.
+ (setLabel): Fire PropertyChangeEvent if label property
+ changes.
+ * javax/swing/JRadioButtonMenuItem.java: Fixed javadocs.
+ * javax/swing/plaf/basic/BasicMenuBarUI.java: Likewise.
+ (ContainerHandler): Repaint if margin property has changed.
+ * javax/swing/plaf/basic/BasicMenuItemUI.java:
+ (installUI): Call installComponents().
+ (uninstallUI): Call uinstallComponents().
+ * javax/swing/plaf/basic/BasicMenuUI.java:
+ Fixed javadocs.
+ * javax/swing/plaf/basic/BasicPopupMenuUI.java:
+ Likewise.
+
2004-07-13 Kim Ho <kho@redhat.com>
* javax/swing/plaf/basic/BasicToolBarUI.java:
Index: javax/swing/JCheckBoxMenuItem.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JCheckBoxMenuItem.java,v
retrieving revision 1.3.8.7
diff -c -p -u -r1.3.8.7 JCheckBoxMenuItem.java
--- javax/swing/JCheckBoxMenuItem.java 21 Jun 2004 15:11:55 -0000 1.3.8.7
+++ javax/swing/JCheckBoxMenuItem.java 13 Jul 2004 15:34:08 -0000
@@ -45,7 +45,11 @@ import javax.accessibility.AccessibleRol
/**
- * JCheckBoxMenuItem
+ * This class represents JCheckBoxMenuItem. Its behaviour is very similar
+ * to JCheckBoxButton. Just like the JCheckBoxButton, user can check and
+ * uncheck this menu item by clicking on it. Also setSelected()/setState()
+ * can be use used for the same purpose. JCheckBoxMenuItem uses
+ * ToggleButtonModel to keep track of its selection.
*/
public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
Accessible
Index: javax/swing/JMenu.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JMenu.java,v
retrieving revision 1.3.8.10
diff -c -p -u -r1.3.8.10 JMenu.java
--- javax/swing/JMenu.java 6 Jul 2004 14:43:13 -0000 1.3.8.10
+++ javax/swing/JMenu.java 13 Jul 2004 15:34:08 -0000
@@ -62,9 +62,19 @@ import javax.swing.plaf.MenuItemUI;
/**
+ * <p>
* This class represents a menu that can be added to a menu bar or
- * to some other menu. When JMenu is selected it displays JPopupMenu
- * containing its menu items.
+ * can be a submenu in some other menu. When JMenu is selected it
+ * displays JPopupMenu containing its menu items.
+ * </p>
+ *
+ * <p>
+ * JMenu's fires MenuEvents when this menu's selection changes. If this menu
+ * is selected, then fireMenuSelectedEvent() is invoked. In case when menu is
+ * deselected or cancelled, then fireMenuDeselectedEvent() or
+ * fireMenuCancelledEvent() is invoked, respectivelly.
+ * </p>
+ *
*/
public class JMenu extends JMenuItem implements Accessible, MenuElement
{
@@ -76,7 +86,8 @@ public class JMenu extends JMenuItem imp
/** A Popup menu associated with this menu, which pops up when menu is selected */
private JPopupMenu popupMenu = new JPopupMenu();
- /** MenuEvent */
+ /** Whenever menu is selected or deselected the MenuEvent is fired to
+ menu's registered listeners. */
private MenuEvent menuEvent = new MenuEvent(this);
/*Amount of time, in milliseconds, that should pass before popupMenu
@@ -86,7 +97,8 @@ public class JMenu extends JMenuItem imp
/* PopupListener */
protected WinListener popupListener;
- /** Location at which popup menu associated with this menu will be displayed*/
+ /** Location at which popup menu associated with this menu will be
+ displayed */
private Point menuLocation;
/**
@@ -327,7 +339,7 @@ public class JMenu extends JMenuItem imp
/**
* Changes this menu selected state if selected is true and false otherwise
- * This method fires menuEvents to model's registered listeners.
+ * This method fires menuEvents to menu's registered listeners.
*
* @param selected true if the menu should be selected and false otherwise
*/
@@ -340,6 +352,9 @@ public class JMenu extends JMenuItem imp
super.setArmed(true);
super.setSelected(true);
+ // FIXME: The popup menu should be shown on the screen after certain
+ // number of seconds pass. The 'delay' property of this menu indicates
+ // this amount of seconds. 'delay' property is 0 by default.
if (this.isShowing())
{
fireMenuSelected();
Index: javax/swing/JMenuBar.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JMenuBar.java,v
retrieving revision 1.2.18.5
diff -c -p -u -r1.2.18.5 JMenuBar.java
--- javax/swing/JMenuBar.java 14 Jun 2004 14:16:58 -0000 1.2.18.5
+++ javax/swing/JMenuBar.java 13 Jul 2004 15:34:08 -0000
@@ -1,4 +1,4 @@
-/* JMenuBar.java --
+/* JMenuBar.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -66,7 +66,15 @@ import javax.swing.plaf.MenuItemUI;
/**
- * JMenuBar
+ * <p>
+ * JMenuBar is a container for menu's. For a menu bar to be seen on the
+ * screen, at least one menu should be added to it. Just like adding
+ * components to container, one can use add() to add menu's to the menu bar.
+ * Menu's will be displayed in the menu bar in the order they were added.
+ * The JMenuBar uses selectionModel to keep track of selected menu index.
+ * JMenuBar's selectionModel will fire ChangeEvents to its registered
+ * listeners when the selected index changes.
+ * </p>
*/
public class JMenuBar extends JComponent implements Accessible, MenuElement
{
@@ -75,7 +83,9 @@ public class JMenuBar extends JComponent
/** Fired in a PropertyChangeEvent when the "model" changes. */
public static final String MODEL_CHANGED_PROPERTY = "model";
-
+
+ /** Fired in a PropertyChangeEvent when the "margin" changes. */
+ public static final String MARGIN_CHANGED_PROPERTY = "margin";
private static final long serialVersionUID = -8191026883931977036L;
/** JMenuBar's model. It keeps track of selected menu's index */
@@ -112,7 +122,8 @@ public class JMenuBar extends JComponent
}
/**
- * DOCUMENT ME!
+ * This method overrides addNotify() in the Container to register
+ * this menu bar with the current keyboard manager.
*/
public void addNotify()
{
@@ -216,9 +227,9 @@ public class JMenuBar extends JComponent
}
/**
- * DOCUMENT ME!
+ * Returns number of menu's in this menu bar
*
- * @return DOCUMENT ME!
+ * @return number of menu's in this menu bar
*/
public int getMenuCount()
{
@@ -226,9 +237,12 @@ public class JMenuBar extends JComponent
}
/**
- * Returns selection model for this menu bar.
+ * Returns selection model for this menu bar. SelectionModel
+ * keeps track of the selected menu in the menu bar. Whenever
+ * selected property of selectionModel changes, the ChangeEvent
+ * will be fired its ChangeListeners.
*
- * @return selection mdoel for this menu bar.
+ * @return selection model for this menu bar.
*/
public SingleSelectionModel getSelectionModel()
{
@@ -297,7 +311,7 @@ public class JMenuBar extends JComponent
* This method does nothing by default. This method is need for the
* MenuElement interface to be implemented.
*
- * @param isIncluded true if menuBar is included in the selection
+ * @param isIncluded true if menuBar is included in the selection
* and false otherwise
*/
public void menuSelectionChanged(boolean isIncluded)
@@ -306,7 +320,7 @@ public class JMenuBar extends JComponent
}
/**
- * Paints border of the menu bar, if its borderPainted property is set to
+ * Paints border of the menu bar, if its borderPainted property is set to
* true.
*
* @param g The graphics context with which to paint the border
@@ -319,9 +333,10 @@ public class JMenuBar extends JComponent
}
/**
- * DOCUMENT ME!
+ * A string that describes this JMenuBar. Normally only used
+ * for debugging.
*
- * @return DOCUMENT ME!
+ * @return A string describing this JMenuBar
*/
protected String paramString()
{
@@ -329,11 +344,13 @@ public class JMenuBar extends JComponent
}
/**
- * DOCUMENT ME!
+ * Process key events forwarded from MenuSelectionManager. This method
+ * doesn't do anything. It is here to conform to the MenuElement interface.
+ *
+ * @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
*
- * @param e DOCUMENT ME!
- * @param path DOCUMENT ME!
- * @param manager DOCUMENT ME!
*/
public void processKeyEvent(KeyEvent e, MenuElement[] path,
MenuSelectionManager manager)
@@ -342,11 +359,13 @@ public class JMenuBar extends JComponent
}
/**
- * DOCUMENT ME!
+ * Process mouse events forwarded from MenuSelectionManager. This method
+ * doesn't do anything. It is here to conform to the MenuElement interface.
+ *
+ * @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
*
- * @param event DOCUMENT ME!
- * @param path DOCUMENT ME!
- * @param manager DOCUMENT ME!
*/
public void processMouseEvent(MouseEvent event, MenuElement[] path,
MenuSelectionManager manager)
@@ -355,7 +374,8 @@ public class JMenuBar extends JComponent
}
/**
- * DOCUMENT ME!
+ * This method overrides removeNotify() in the Container to
+ * unregister this menu bar from the current keyboard manager.
*/
public void removeNotify()
{
@@ -364,9 +384,10 @@ public class JMenuBar extends JComponent
}
/**
- * DOCUMENT ME!
+ * Sets painting status of the border. If 'b' is true then menu bar's
+ * border will be painted, and it will not be painted otherwise.
*
- * @param b DOCUMENT ME!
+ * @param b indicates if menu bar's border should be painted.
*/
public void setBorderPainted(boolean b)
{
@@ -381,27 +402,38 @@ public class JMenuBar extends JComponent
}
/**
- * DOCUMENT ME!
+ * Sets help menu for this menu bar
*
- * @param menu DOCUMENT ME!
+ * @param menu help menu
*/
public void setHelpMenu(JMenu menu)
{
}
/**
- * DOCUMENT ME!
+ * Sets the menu bar's "margin" bound property, which represents
+ * distance between the menubar's border and its menus.
+ * icon. When marging property is modified, PropertyChangeEvent will
+ * be fired to menuBar's PropertyChangeListener's.
+ *
+ * @param m distance between the menubar's border and its menus.
*
- * @param m DOCUMENT ME!
*/
public void setMargin(Insets m)
{
+ if (m.equals(this.margin))
+ {
+ Insets oldMargin = this.margin;
+ this.margin = m;
+ firePropertyChange(MARGIN_CHANGED_PROPERTY, oldMargin, margin);
+ }
+
this.margin = m;
}
/**
- * Changes menu bar's selection to the specifies menu.
- * This method updates selected index of menu bar's model,
+ * Changes menu bar's selection to the specified menu.
+ * This method updates selected index of menu bar's selection model,
* which results in a model firing change event.
*
* @param sel menu to select
Index: javax/swing/JMenuItem.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JMenuItem.java,v
retrieving revision 1.2.18.12
diff -c -p -u -r1.2.18.12 JMenuItem.java
--- javax/swing/JMenuItem.java 10 Jul 2004 17:53:03 -0000 1.2.18.12
+++ javax/swing/JMenuItem.java 13 Jul 2004 15:34:08 -0000
@@ -171,12 +171,10 @@ public class JMenuItem extends AbstractB
// Initializes properties for this menu item, that are different
// from Abstract button properties.
-
/* NOTE: According to java specifications paint_border should be set to false,
since menu item should not have a border. However running few java programs
it seems that menu items and menues can have a border. Commenting
out statement below for now. */
-
//borderPainted = false;
focusPainted = false;
horizontalAlignment = JButton.LEFT;
@@ -331,11 +329,11 @@ public class JMenuItem extends AbstractB
if (isRolloverEnabled())
model.setRollover(false);
- // for JMenu last element on the path is its popupMenu.
- // JMenu shouldn't me disarmed.
- if (!(path[path.length-1] instanceof JPopupMenu) && !dragged)
- setArmed(false);
- break;
+ // for JMenu last element on the path is its popupMenu.
+ // JMenu shouldn't me disarmed.
+ if (! (path[path.length - 1] instanceof JPopupMenu) && ! dragged)
+ setArmed(false);
+ break;
case MouseEvent.MOUSE_PRESSED:
if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
{
@@ -353,13 +351,14 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Creates MenuDragMouseEvent.
*
- * @param event DOCUMENT ME!
- * @param path DOCUMENT ME!
- * @param manager DOCUMENT ME!
+ * @param event MouseEvent that occured while mouse was pressed.
+ * @param path Path the the menu element where the dragging event was
+ * originated
+ * @param manager MenuSelectionManager for the current menu hierarchy.
*
- * @return DOCUMENT ME!
+ * @return new MenuDragMouseEvent
*/
private MenuDragMouseEvent createMenuDragMouseEvent(MouseEvent event,
MenuElement[] path,
@@ -373,16 +372,16 @@ public class JMenuItem extends AbstractB
}
/**
- * DOCUMENT ME!
+ * Process key 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 processKeyEvent(KeyEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
- // TODO
+ // Need to implement.
}
/**
@@ -420,7 +419,7 @@ public class JMenuItem extends AbstractB
*/
public void processMenuKeyEvent(MenuKeyEvent event)
{
- // TODO
+ // Need to implement.
}
/**
@@ -621,11 +620,6 @@ public class JMenuItem extends AbstractB
return "JMenuItem";
}
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
Index: javax/swing/JPopupMenu.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JPopupMenu.java,v
retrieving revision 1.3.8.12
diff -c -p -u -r1.3.8.12 JPopupMenu.java
--- javax/swing/JPopupMenu.java 6 Jul 2004 14:43:13 -0000 1.3.8.12
+++ javax/swing/JPopupMenu.java 13 Jul 2004 15:34:08 -0000
@@ -68,7 +68,30 @@ import javax.swing.plaf.PopupMenuUI;
/**
- * DOCUMENT ME!
+ * JPopupMenu is a container that is used to display popup menu's menu
+ * items. By default JPopupMenu is a lightweight container, however if it
+ * is the case that JPopupMenu's bounds are outside of main window, then
+ * heawyweight container will be used to display menu items. It is also
+ * possible to change JPopupMenu's default behavior and set JPopupMenu
+ * to always use heavyweight container.
+ *
+ * JPopupMenu can be displayed anywhere; it is a floating free popup menu.
+ * However before JPopupMenu is diplayed, its invoker property should be set.
+ * JPopupMenu's invoker is a component relative to which popup menu is
+ * displayed.
+ *
+ * JPopupMenu fires PopupMenuEvents to its registered listeners. Whenever
+ * JPopupMenu becomes visible on the screen then PopupMenuEvent indicating
+ * that popup menu became visible will be fired. In the case when
+ * JPopupMenu becomes invisible or cancelled without selection, then
+ * popupMenuBecomeInvisible() or popupMenuCancelled() methods of
+ * PopupMenuListeners will be invoked.
+ *
+ * JPopupMenu also fires PropertyChangeEvents when its bound properties
+ * change.In addittion to inheritted bound properties, JPopupMenu has
+ * 'visible' bound property. When JPopupMenu becomes visible/invisible on
+ * the screen it fires PropertyChangeEvents to its registered
+ * PropertyChangeListeners.
*/
public class JPopupMenu extends JComponent implements Accessible, MenuElement
{
@@ -77,6 +100,9 @@ public class JPopupMenu extends JCompone
/** name for the UI delegate for this menuItem. */
private static final String uiClassID = "PopupMenuUI";
+ /** Fire a PropertyChangeEvent when the "borderPainted" property changes. */
+ public static final String LABEL_CHANGED_PROPERTY = "label";
+
/* indicates if popup's menu border should be painted*/
private boolean borderPainted = true;
@@ -98,7 +124,7 @@ public class JPopupMenu extends JCompone
/* Component that invokes popup menu. */
transient Component invoker;
- /* Label for this popup menu */
+ /* Label for this popup menu. It is not used in most of the look and feel themes. */
private String label;
/*Amount of space between menuItem's in JPopupMenu and JPopupMenu's border */
@@ -140,29 +166,14 @@ public class JPopupMenu extends JCompone
*/
public JPopupMenu(String label)
{
- this.label = label;
+ setLabel(label);
}
- /**
- * DOCUMENT ME!
- *
- * @param stream DOCUMENT ME!
- *
- * @throws IOException DOCUMENT ME!
- * @throws ClassNotFoundException DOCUMENT ME!
- */
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException
{
}
- /**
- * DOCUMENT ME!
- *
- * @param stream DOCUMENT ME!
- *
- * @throws IOException DOCUMENT ME!
- */
private void writeObject(ObjectOutputStream stream) throws IOException
{
}
@@ -204,7 +215,7 @@ public class JPopupMenu extends JCompone
*/
public JMenuItem add(Action action)
{
- JMenuItem item = new JMenuItem(action);
+ JMenuItem item = createActionComponent(action);
if (action != null)
action.addPropertyChangeListener(createActionChangeListener(item));
@@ -384,15 +395,15 @@ public class JPopupMenu extends JCompone
}
/**
- * DOCUMENT ME!
+ * Creates new menu item associated with a given action.
*
- * @param action DOCUMENT ME!
+ * @param action Action used to create new menu item
*
- * @return DOCUMENT ME!
+ * @return new created menu item associated with a given action.
*/
protected JMenuItem createActionComponent(Action action)
{
- return null;
+ return new JMenuItem(action);
}
/**
@@ -441,13 +452,20 @@ public class JPopupMenu extends JCompone
}
/**
- * Sets label for this popup menu
+ * Sets label for this popup menu. This method fires PropertyChangeEvent
+ * when the label property is changed. Please note that most
+ * of the Look & Feel will ignore this property.
*
* @param label label for this popup menu
*/
public void setLabel(String label)
{
- this.label = label;
+ if (label != this.label)
+ {
+ String oldLabel = this.label;
+ this.label = label;
+ firePropertyChange(LABEL_CHANGED_PROPERTY, oldLabel, label);
+ }
}
/**
@@ -576,6 +594,7 @@ public class JPopupMenu extends JCompone
size = this.getPreferredSize();
else
size = this.getSize();
+
if ((size.width > (rootContainer.getWidth() - popupLocation.x))
|| (size.height > (rootContainer.getHeight() - popupLocation.y)))
fit = false;
@@ -778,7 +797,8 @@ public class JPopupMenu extends JCompone
}
/**
- * Process mouse events forwarded from MenuSelectionManager.
+ * Process mouse events forwarded from MenuSelectionManager. This method
+ * doesn't do anything. It is here to conform to the MenuElement interface.
*
* @param event event forwarded from MenuSelectionManager
* @param path path to the menu element from which event was generated
@@ -792,11 +812,13 @@ public class JPopupMenu extends JCompone
}
/**
- * DOCUMENT ME!
+ * Process key events forwarded from MenuSelectionManager. This method
+ * doesn't do anything. It is here to conform to the MenuElement interface.
+ *
+ * @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
*
- * @param event DOCUMENT ME!
- * @param path DOCUMENT ME!
- * @param manager DOCUMENT ME!
*/
public void processKeyEvent(KeyEvent event, MenuElement[] path,
MenuSelectionManager manager)
@@ -932,6 +954,9 @@ public class JPopupMenu extends JCompone
*/
public void hide()
{
+ // FIXME: Right now the lightweight container is removed from JLayered
+ // pane. It is probably would be better in order to improve performance
+ // to make the container invisible instead of removing it everytime.
JLayeredPane layeredPane;
layeredPane = SwingUtilities.getRootPane(invoker).getLayeredPane();
int index = layeredPane.getIndexOf(c);
@@ -976,6 +1001,9 @@ public class JPopupMenu extends JCompone
*/
public void hide()
{
+ // FIXME: Right now the lightweight container is removed from JLayered
+ // pane. It is probably would be better in order to improve performance
+ // to make the container invisible instead of removing it everytime.
JLayeredPane layeredPane;
layeredPane = SwingUtilities.getRootPane(invoker).getLayeredPane();
int index = layeredPane.getIndexOf(this);
@@ -1022,6 +1050,9 @@ public class JPopupMenu extends JCompone
}
}
+ /**
+ * This is the separator that can be used in popup menu.
+ */
public static class Separator extends JSeparator
{
public Separator()
Index: javax/swing/JRadioButtonMenuItem.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JRadioButtonMenuItem.java,v
retrieving revision 1.3.8.9
diff -c -p -u -r1.3.8.9 JRadioButtonMenuItem.java
--- javax/swing/JRadioButtonMenuItem.java 24 Jun 2004 05:31:32 -0000 1.3.8.9
+++ javax/swing/JRadioButtonMenuItem.java 13 Jul 2004 15:34:08 -0000
@@ -46,9 +46,13 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-
/**
- * JRadioButtonMenuItem.
+ * This class represents JRadioButtonMenuItem. Its behaviour is very similar
+ * to JRadioButton. Just like JRadioButton, user can check and uncheck this
+ * menu item by clicking on it. JRadioButtonMenuItem uses ToggleButtonModel
+ * to keep track of its selection. If the JRadioButtonMenuItem is included in
+ * the button group, then only one JRadioButtonMenuItem can be selected at
+ * one time.
*/
public class JRadioButtonMenuItem extends JMenuItem implements Accessible
{
Index: javax/swing/plaf/basic/BasicMenuBarUI.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicMenuBarUI.java,v
retrieving revision 1.1.2.5
diff -c -p -u -r1.1.2.5 BasicMenuBarUI.java
--- javax/swing/plaf/basic/BasicMenuBarUI.java 30 Jun 2004 16:33:07 -0000 1.1.2.5
+++ javax/swing/plaf/basic/BasicMenuBarUI.java 13 Jul 2004 15:34:08 -0000
@@ -101,9 +101,9 @@ public class BasicMenuBarUI extends Menu
}
/**
- * DOCUMENT ME!
+ * Creates ChangeListener
*
- * @return DOCUMENT ME!
+ * @return The ChangeListener
*/
protected ChangeListener createChangeListener()
{
@@ -112,7 +112,7 @@ public class BasicMenuBarUI extends Menu
/**
* Creates ContainerListener() to listen for ContainerEvents
- * fired by JMenuBar
+ * fired by JMenuBar.
*
* @return The ContainerListener
*/
@@ -242,7 +242,7 @@ public class BasicMenuBarUI extends Menu
}
/**
- * DOCUMENT ME!
+ * Unregisters all the listeners that this UI delegate was using.
*/
protected void uninstallListeners()
{
@@ -273,7 +273,8 @@ public class BasicMenuBarUI extends Menu
}
/**
- * This class handles ContainerEvents fired by JMenuBar
+ * This class handles ContainerEvents fired by JMenuBar. It revalidates
+ * and repaints menu bar whenever menu is added or removed from it.
*/
protected class ContainerHandler implements ContainerListener
{
@@ -315,6 +316,8 @@ public class BasicMenuBarUI extends Menu
{
if (e.getPropertyName().equals(JMenuBar.BORDER_PAINTED_CHANGED_PROPERTY))
menuBar.repaint();
+ if (e.getPropertyName().equals(JMenuBar.MARGIN_CHANGED_PROPERTY))
+ menuBar.repaint();
}
}
}
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.16
diff -c -p -u -r1.1.2.16 BasicMenuItemUI.java
--- javax/swing/plaf/basic/BasicMenuItemUI.java 9 Jul 2004 20:11:20 -0000 1.1.2.16
+++ javax/swing/plaf/basic/BasicMenuItemUI.java 13 Jul 2004 15:34:08 -0000
@@ -367,11 +367,6 @@ public class BasicMenuItemUI extends Men
return getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap);
}
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
protected String getPropertyPrefix()
{
return null;
@@ -441,6 +436,7 @@ public class BasicMenuItemUI extends Men
super.installUI(c);
menuItem = (JMenuItem) c;
installDefaults();
+ installComponents(menuItem);
installListeners();
}
@@ -537,6 +533,7 @@ public class BasicMenuItemUI extends Men
}
}
+ // If this menu item is a JCheckBoxMenuItem then paint check icon
if (checkIcon != null)
{
SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign,
@@ -551,6 +548,7 @@ public class BasicMenuItemUI extends Men
vr.x = cr.x + cr.width + defaultTextIconGap;
}
+ // if this is a submenu, then paint arrow icon to indicate it.
if (arrowIcon != null && (c instanceof JMenu))
{
if (! ((JMenu) c).isTopLevelMenu())
@@ -705,6 +703,7 @@ public class BasicMenuItemUI extends Men
{
uninstallListeners();
uninstallDefaults();
+ uninstallComponents(menuItem);
menuItem = null;
}
Index: javax/swing/plaf/basic/BasicMenuUI.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicMenuUI.java,v
retrieving revision 1.1.2.9
diff -c -p -u -r1.1.2.9 BasicMenuUI.java
--- javax/swing/plaf/basic/BasicMenuUI.java 9 Jul 2004 20:11:20 -0000 1.1.2.9
+++ javax/swing/plaf/basic/BasicMenuUI.java 13 Jul 2004 15:34:08 -0000
@@ -443,12 +443,12 @@ public class BasicMenuUI extends BasicMe
}
/**
- * This class handles mouse dragged events.
+ * This class handles mouse dragged events occuring in the menu.
*/
protected class MenuDragMouseHandler implements MenuDragMouseListener
{
/**
- * Tbis method is invoked when mouse is dragged over the menu item.
+ * This method is invoked when mouse is dragged over the menu item.
*
* @param e The MenuDragMouseEvent
*/
@@ -459,7 +459,7 @@ public class BasicMenuUI extends BasicMe
}
/**
- * Tbis method is invoked when mouse enters the menu item while it is
+ * This method is invoked when mouse enters the menu item while it is
* being dragged.
*
* @param e The MenuDragMouseEvent
@@ -471,7 +471,7 @@ public class BasicMenuUI extends BasicMe
}
/**
- * Tbis method is invoked when mouse exits the menu item while
+ * This method is invoked when mouse exits the menu item while
* it is being dragged
*
* @param e The MenuDragMouseEvent
@@ -481,7 +481,7 @@ public class BasicMenuUI extends BasicMe
}
/**
- * Tbis method is invoked when mouse was dragged and released
+ * This method is invoked when mouse was dragged and released
* inside the menu item.
*
* @param e The MenuDragMouseEvent
Index: javax/swing/plaf/basic/BasicPopupMenuUI.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicPopupMenuUI.java,v
retrieving revision 1.1.2.5
diff -c -p -u -r1.1.2.5 BasicPopupMenuUI.java
--- javax/swing/plaf/basic/BasicPopupMenuUI.java 9 Jul 2004 20:11:20 -0000 1.1.2.5
+++ javax/swing/plaf/basic/BasicPopupMenuUI.java 13 Jul 2004 15:34:08 -0000
@@ -264,11 +264,13 @@ public class BasicPopupMenuUI extends Po
}
/**
- * DOCUMENT ME!
+ * Return true if given mouse event is a platform popup trigger,
+ * and false otherwise
*
- * @param e DOCUMENT ME!
+ * @param e MouseEvent that is to be checked for popup trigger event
*
- * @return DOCUMENT ME!
+ * @return true if given mouse event is a platform popup trigger,
+ * and false otherwise
*/
public boolean isPopupTrigger(MouseEvent e)
{
@@ -281,7 +283,7 @@ public class BasicPopupMenuUI extends Po
private class PopupMenuHandler implements PopupMenuListener
{
/**
- * This method is invoked when JPopupMenu is cancelled
+ * This method is invoked when JPopupMenu is cancelled.
*
* @param event the PopupMenuEvent
*/
@@ -299,7 +301,7 @@ public class BasicPopupMenuUI extends Po
public void popupMenuWillBecomeInvisible(PopupMenuEvent event)
{
// remove listener that listens to component events fired
- // by the top - level window that this popup belongs to
+ // by the top - level window that this popup belongs to.
Component invoker = popupMenu.getInvoker();
Container rootContainer = (Container) SwingUtilities.getRoot(invoker);
@@ -314,7 +316,8 @@ public class BasicPopupMenuUI extends Po
public void popupMenuWillBecomeVisible(PopupMenuEvent event)
{
// Adds topWindowListener to top-level window to listener to
- // ComponentEvents fired by it.
+ // ComponentEvents fired by it. We need to cancel this popup menu
+ // if topWindow to which this popup belongs was resized or moved.
Component invoker = popupMenu.getInvoker();
Container rootContainer = (Container) SwingUtilities.getRoot(invoker);
rootContainer.addComponentListener(topWindowListener);
@@ -396,70 +399,32 @@ public class BasicPopupMenuUI extends Po
}
}
- /**
- * DOCUMENT ME!
- */
private class MouseInputHandler implements MouseInputListener
{
- /**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
- */
public void mouseClicked(MouseEvent e)
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
- */
public void mouseDragged(MouseEvent e)
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
- */
public void mouseEntered(MouseEvent e)
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
- */
public void mouseExited(MouseEvent e)
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
- */
public void mouseMoved(MouseEvent e)
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
- */
public void mousePressed(MouseEvent e)
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
- */
public void mouseReleased(MouseEvent e)
{
}
More information about the Java-patches
mailing list