|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.AbstractButton javax.swing.JMenuItem javax.swing.JMenu com.jidesoft.swing.JideMenu
public class JideMenu
A special implementation of JMenu. It is used to replace JMenu in order to use with CommandBar.
It has two
special features. First, it has a PopupMenuCustomizer for lazy menu creation. Instead of creating menu upfront which
might be quite expensive, you can create it using PopupMenuCustomizer. PopupMenuCustomizer is called before the menu
is set visible. Please note, when you use PopupMenuCustomizer, you need to remove the old menu items you added
previously using PopupMenuCustomizer. Otherwise, you will see a menu which gets longer and longer when you show it.
See below for an example.
JideMenu jideMenu = new JideMenu("Dynamic");
jideMenu.setPopupMenuCustomizer(new JideMenu.PopupMenuCustomizer(){
public void customize(JPopupMenu menu) {
menu.add("item 1");
menu.add("item 2");
menu.add("item 3");
menu.add("item 4");
menu.add("item 5");
}
});
Nested Class Summary | |
---|---|
static interface |
JideMenu.MenuCreator
Deprecated. The createMenu method of MenuCreator should JPopupMenu as parameter. Since it's a public API we have to deprecated this one and ask users to use JideMenu.PopupMenuCustomizer instead. |
static interface |
JideMenu.PopupMenuCustomizer
Customizes the popup menu. |
static interface |
JideMenu.PopupMenuOriginCalculator
Calculates the origin of the popup menu if specified. |
Nested classes/interfaces inherited from class javax.swing.JMenu |
---|
JMenu.AccessibleJMenu, JMenu.WinListener |
Nested classes/interfaces inherited from class javax.swing.JMenuItem |
---|
JMenuItem.AccessibleJMenuItem |
Nested classes/interfaces inherited from class javax.swing.AbstractButton |
---|
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
DELAY
|
Fields inherited from class javax.swing.JMenu |
---|
popupListener |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface com.jidesoft.swing.Alignable |
---|
PROPERTY_ORIENTATION |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JideMenu()
|
|
JideMenu(Action a)
|
|
JideMenu(String s)
|
|
JideMenu(String s,
boolean b)
|
Method Summary | |
---|---|
JideMenu.MenuCreator |
getMenuCreator()
Deprecated. use JideMenu.PopupMenuCustomizer and getPopupMenuCustomizer() instead. |
int |
getOrientation()
Gets the orientation. |
JideMenu.PopupMenuOriginCalculator |
getOriginCalculator()
Gets the PopupMenuOriginCalculator or null , if none has been specified. |
JideMenu.PopupMenuCustomizer |
getPopupMenuCustomizer()
Gets the PopupMenuCustomizer. |
protected Point |
getPopupMenuOrigin()
|
int |
getPreferredPopupHorizontalAlignment()
|
int |
getPreferredPopupVerticalAlignment()
|
protected void |
hideMenu()
|
protected void |
initMenu()
|
boolean |
isOpaque()
Checks if the |
boolean |
isTopLevelMenu()
Checks if the menu is added to a top level menu container. |
boolean |
originalIsOpaque()
|
void |
setMenuCreator(JideMenu.MenuCreator menuCreator)
Deprecated. use JideMenu.PopupMenuCustomizer and setPopupMenuCustomizer(com.jidesoft.swing.JideMenu.PopupMenuCustomizer)
instead. |
void |
setOrientation(int orientation)
Changes the orientation. |
void |
setOriginCalculator(JideMenu.PopupMenuOriginCalculator originCalculator)
Sets the PopupMenuOriginCalculator that will be used to determine the popup menu origin. |
void |
setPopupMenuCustomizer(JideMenu.PopupMenuCustomizer customizer)
Sets the PopupMenuCustomizer. |
void |
setPopupMenuVisible(boolean b)
|
void |
setPreferredPopupHorizontalAlignment(int preferredPopupHorizontalAlignment)
|
void |
setPreferredPopupVerticalAlignment(int preferredPopupVerticalAlignment)
|
protected boolean |
shouldHidePopupMenu()
Check if the popup menu should stay hidden although setPopupMenuVisible(boolean) is invoked. |
boolean |
supportHorizontalOrientation()
Checks if the component support horizontal orientation. |
boolean |
supportVerticalOrientation()
Checks if the component support vertical orientation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface javax.swing.MenuElement |
---|
processKeyEvent, processMouseEvent |
Field Detail |
---|
public static int DELAY
Constructor Detail |
---|
public JideMenu()
public JideMenu(String s)
public JideMenu(Action a)
public JideMenu(String s, boolean b)
Method Detail |
---|
protected void initMenu()
public boolean isTopLevelMenu()
isTopLevelMenu
in class JMenu
public JideMenu.PopupMenuOriginCalculator getOriginCalculator()
null
, if none has been specified.
public void setOriginCalculator(JideMenu.PopupMenuOriginCalculator originCalculator)
originCalculator
- the calculator@Deprecated public JideMenu.MenuCreator getMenuCreator()
JideMenu.PopupMenuCustomizer
and getPopupMenuCustomizer()
instead.
@Deprecated public void setMenuCreator(JideMenu.MenuCreator menuCreator)
JideMenu.PopupMenuCustomizer
and setPopupMenuCustomizer(com.jidesoft.swing.JideMenu.PopupMenuCustomizer)
instead.
menuCreator
- he menu creatorpublic JideMenu.PopupMenuCustomizer getPopupMenuCustomizer()
public void setPopupMenuCustomizer(JideMenu.PopupMenuCustomizer customizer)
JideMenu menu = new JideMenu();
menu.add(new JMenuItem("..."));
menu.add(new JMenuItem("..."));
You can do
JideMenu menu = new JideMenu();
menu.setPopupMenuCustomzier(new JideMenu.PopupMenuCustomizer() {
void customize(JPopupMenu popupMenu) {
poupMenu.removeAll();
popupMenu.add(new JMenuItem("..."));
popupMenu.add(new JMenuItem("..."));
}
}
If the menu is never used, the two add methods will never be called thus improve the performance.
customizer
- the popup menu customizerprotected Point getPopupMenuOrigin()
getPopupMenuOrigin
in class JMenu
public boolean isOpaque()
isOpaque
in class JComponent
public boolean originalIsOpaque()
protected void hideMenu()
public int getPreferredPopupHorizontalAlignment()
public void setPreferredPopupHorizontalAlignment(int preferredPopupHorizontalAlignment)
public int getPreferredPopupVerticalAlignment()
public void setPreferredPopupVerticalAlignment(int preferredPopupVerticalAlignment)
public boolean supportVerticalOrientation()
Alignable
supportVerticalOrientation
in interface Alignable
public boolean supportHorizontalOrientation()
Alignable
supportHorizontalOrientation
in interface Alignable
public void setOrientation(int orientation)
Alignable
JideSwingUtilities.setOrientationOf(this, orientation);
- Specified by:
setOrientation
in interface Alignable
- Parameters:
orientation
- the new orientation
public int getOrientation()
Alignable
return
JideSwingUtilities.getOrientationOf(this);
- Specified by:
getOrientation
in interface Alignable
- Returns:
- orientation
public void setPopupMenuVisible(boolean b)
setPopupMenuVisible
in class JMenu
protected boolean shouldHidePopupMenu()
setPopupMenuVisible(boolean)
is invoked.
The default implementation is to check if it contains any menu items. You could override this method to change the
default behavior.
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |