Extension SDK 10.1.2

oracle.ide.controls
Class SortedMenuLayout

java.lang.Object
  extended byjavax.swing.BoxLayout
      extended byjavax.swing.plaf.basic.DefaultMenuLayout
          extended byoracle.ide.controls.SortedMenuLayout
All Implemented Interfaces:
java.util.EventListener, java.awt.LayoutManager, java.awt.LayoutManager2, java.beans.PropertyChangeListener, java.io.Serializable, javax.swing.plaf.UIResource

Deprecated. No replacement -- experimental class which never worked properly.

public class SortedMenuLayout
extends javax.swing.plaf.basic.DefaultMenuLayout
implements java.beans.PropertyChangeListener

### NOTE: This class has been temporarily disabled.

SortedMenuLayout is an implementation of LayoutManager2 that can be used to order the items displayed in a JPopupMenu in Locale-sensitive collation order. It is a subclass of DefaultMenuLayout.

(In actuality, any arbitrary Container can have its children sorted using this LayoutManager, but in practice only a JPopupMenu is likely to want its children sorted in this fashion.)

Each child of the target Container must be an instance of AbstractButton. The children are ordered according to the value returned by each child's AbstractButton.getText() method.

When the target to be ordered is a JMenu, then general usage pattern is:

    import javax.swing.JMenu;
    import javax.swing.JPopupMenu;
    import oracle.ide.controls.SortedMenuLayout;
    // ...
    final JMenu menu = new JMenu();
    final JPopupMenu popup = menu.getPopupMenu();
    popup.setLayout(new SortedMenuLayout(popup));
 
The general usage pattern for a JPopupMenu is similar:
    import javax.swing.JPopupMenu;
    import oracle.ide.controls.SortedMenuLayout;
    // ...
    final JPopupMenu popup = new JPopupMenu():
    popup.setInvoker(<invoker>);
    popup.setLayout(new SortedMenuLayout(popup));
 
(The reason for calling JPopupMenu.setInvoker(Component) on the popup menu is so that the layout on the popup won't be reset when the invoker is set on the popup in response to a call to JPopupMenu.show(Component,int,int).)

See Also:
Serialized Form

Field Summary
protected  java.util.SortedMap componentMap
          Deprecated. The SortedMap used to maintain child components in sorted order.
protected  boolean isVertical
          Deprecated. Flag indicating whether to layout vertically or horizontally.
 
Fields inherited from class javax.swing.BoxLayout
LINE_AXIS, PAGE_AXIS, X_AXIS, Y_AXIS
 
Constructor Summary
SortedMenuLayout(java.awt.Container target)
          Deprecated. Constructs a SortedMenuLayout for the target container using a vertical orientation.
SortedMenuLayout(java.awt.Container target, int axis)
          Deprecated. Constructs a SortedMenuLayout for the target container using the specified axis for orientation.
 
Method Summary
 void addLayoutComponent(java.awt.Component component, java.lang.Object constraints)
          Deprecated. Adds the component to the componentMap and starts listening for changes to the component's text property.
 void layoutContainer(java.awt.Container target)
          Deprecated. Lays out the container using the appropriate orientation.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Deprecated. Listens for changes to the AbstractButton.TEXT_CHANGED_PROPERTY of any child items.
 void removeLayoutComponent(java.awt.Component component)
          Deprecated. Removes the component from the componentMap and stops listening for changes to the component's text property.
 
Methods inherited from class javax.swing.plaf.basic.DefaultMenuLayout
preferredLayoutSize
 
Methods inherited from class javax.swing.BoxLayout
addLayoutComponent, getLayoutAlignmentX, getLayoutAlignmentY, invalidateLayout, maximumLayoutSize, minimumLayoutSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

componentMap

protected java.util.SortedMap componentMap
Deprecated. 
The SortedMap used to maintain child components in sorted order.


isVertical

protected boolean isVertical
Deprecated. 
Flag indicating whether to layout vertically or horizontally.

Constructor Detail

SortedMenuLayout

public SortedMenuLayout(java.awt.Container target)
Deprecated. 
Constructs a SortedMenuLayout for the target container using a vertical orientation.


SortedMenuLayout

public SortedMenuLayout(java.awt.Container target,
                        int axis)
Deprecated. 
Constructs a SortedMenuLayout for the target container using the specified axis for orientation.

See Also:
BoxLayout.X_AXIS, BoxLayout.Y_AXIS
Method Detail

addLayoutComponent

public void addLayoutComponent(java.awt.Component component,
                               java.lang.Object constraints)
Deprecated. 
Adds the component to the componentMap and starts listening for changes to the component's text property. The component must be an instance of AbstractButton.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component component)
Deprecated. 
Removes the component from the componentMap and stops listening for changes to the component's text property. The component must be an instance of AbstractButton.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

layoutContainer

public void layoutContainer(java.awt.Container target)
Deprecated. 
Lays out the container using the appropriate orientation. The superclass is first leveraged to perform the bulk of the work, before reordering the component positions so that they are laid out top-to-bottom or left-to-right according to how the items have been collated.

Specified by:
layoutContainer in interface java.awt.LayoutManager

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Deprecated. 
Listens for changes to the AbstractButton.TEXT_CHANGED_PROPERTY of any child items. A change in the text of one of the items invalidates the layout.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.