Methods Summary |
---|
private static boolean | checkInvokerEqual(javax.swing.MenuElement present, javax.swing.MenuElement last)
Component invokerPresent = present.getComponent();
Component invokerLast = last.getComponent();
if (invokerPresent instanceof JPopupMenu) {
invokerPresent = ((JPopupMenu)invokerPresent).getInvoker();
}
if (invokerLast instanceof JPopupMenu) {
invokerLast = ((JPopupMenu)invokerLast).getInvoker();
}
return (invokerPresent == invokerLast);
|
public static javax.swing.plaf.ComponentUI | createUI(javax.swing.JComponent x)
return new BasicPopupMenuUI();
|
private static boolean | doUnpostPopupOnDeactivation()
if (!checkedUnpostPopup) {
Boolean b = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction <Boolean> () {
public Boolean run() {
String pKey =
"sun.swing.unpostPopupsOnWindowDeactivation";
String value = System.getProperty(pKey, "true");
return Boolean.valueOf(value);
}
}
);
unpostPopup = b.booleanValue();
checkedUnpostPopup = true;
}
return unpostPopup;
|
static javax.swing.MenuElement | findEnabledChild(javax.swing.MenuElement[] e, int fromIndex, boolean forward)
MenuElement result = null;
if (forward) {
result = nextEnabledChild(e, fromIndex+1, e.length-1);
if (result == null) result = nextEnabledChild(e, 0, fromIndex-1);
} else {
result = previousEnabledChild(e, fromIndex-1, 0);
if (result == null) result = previousEnabledChild(e, e.length-1,
fromIndex+1);
}
return result;
|
static javax.swing.MenuElement | findEnabledChild(javax.swing.MenuElement[] e, javax.swing.MenuElement elem, boolean forward)
for (int i=0; i<e.length; i++) {
if (e[i] == elem) {
return findEnabledChild(e, i, forward);
}
}
return null;
|
static javax.swing.ActionMap | getActionMap()
return LazyActionMap.getActionMap(BasicPopupMenuUI.class,
"PopupMenu.actionMap");
|
static javax.swing.MenuElement | getFirstPopup()
MenuSelectionManager msm = MenuSelectionManager.defaultManager();
MenuElement[] p = msm.getSelectedPath();
MenuElement me = null;
for(int i = 0 ; me == null && i < p.length ; i++) {
if (p[i] instanceof JPopupMenu)
me = p[i];
}
return me;
|
static javax.swing.InputMap | getInputMap(javax.swing.JPopupMenu popup, javax.swing.JComponent c)
InputMap windowInputMap = null;
Object[] bindings = (Object[])UIManager.get("PopupMenu.selectedWindowInputMapBindings");
if (bindings != null) {
windowInputMap = LookAndFeel.makeComponentInputMap(c, bindings);
if (!popup.getComponentOrientation().isLeftToRight()) {
Object[] km = (Object[])UIManager.get("PopupMenu.selectedWindowInputMapBindings.RightToLeft");
if (km != null) {
InputMap rightToLeftInputMap = LookAndFeel.makeComponentInputMap(c, km);
rightToLeftInputMap.setParent(windowInputMap);
windowInputMap = rightToLeftInputMap;
}
}
}
return windowInputMap;
|
static javax.swing.JPopupMenu | getLastPopup()
MenuSelectionManager msm = MenuSelectionManager.defaultManager();
MenuElement[] p = msm.getSelectedPath();
JPopupMenu popup = null;
for(int i = p.length - 1; popup == null && i >= 0; i--) {
if (p[i] instanceof JPopupMenu)
popup = (JPopupMenu)p[i];
}
return popup;
|
static java.util.List | getPopups()
MenuSelectionManager msm = MenuSelectionManager.defaultManager();
MenuElement[] p = msm.getSelectedPath();
List list = new ArrayList(p.length);
for(int i = 0; i < p.length; i++) {
if (p[i] instanceof JPopupMenu) {
list.add((JPopupMenu)p[i]);
}
}
return list;
|
public void | installDefaults()
if (popupMenu.getLayout() == null ||
popupMenu.getLayout() instanceof UIResource)
popupMenu.setLayout(new DefaultMenuLayout(popupMenu, BoxLayout.Y_AXIS));
LookAndFeel.installProperty(popupMenu, "opaque", Boolean.TRUE);
LookAndFeel.installBorder(popupMenu, "PopupMenu.border");
LookAndFeel.installColorsAndFont(popupMenu,
"PopupMenu.background",
"PopupMenu.foreground",
"PopupMenu.font");
|
protected void | installKeyboardActions()
|
protected void | installListeners()
if (popupMenuListener == null) {
popupMenuListener = new BasicPopupMenuListener();
}
popupMenu.addPopupMenuListener(popupMenuListener);
if (menuKeyListener == null) {
menuKeyListener = new BasicMenuKeyListener();
}
popupMenu.addMenuKeyListener(menuKeyListener);
if (mouseGrabber == null) {
mouseGrabber = new MouseGrabber();
}
if (!menuKeyboardHelperInstalled) {
if (menuKeyboardHelper == null) {
menuKeyboardHelper = new MenuKeyboardHelper();
}
MenuSelectionManager msm = MenuSelectionManager.defaultManager();
msm.addChangeListener(menuKeyboardHelper);
menuKeyboardHelperInstalled = true;
}
|
public void | installUI(javax.swing.JComponent c)
popupMenu = (JPopupMenu) c;
installDefaults();
installListeners();
installKeyboardActions();
|
public boolean | isPopupTrigger(java.awt.event.MouseEvent e)
return ((e.getID()==MouseEvent.MOUSE_RELEASED)
&& ((e.getModifiers() & MouseEvent.BUTTON3_MASK)!=0));
|
static void | loadActionMap(javax.swing.plaf.basic.LazyActionMap map)
map.put(new Actions(Actions.CANCEL));
map.put(new Actions(Actions.SELECT_NEXT));
map.put(new Actions(Actions.SELECT_PREVIOUS));
map.put(new Actions(Actions.SELECT_PARENT));
map.put(new Actions(Actions.SELECT_CHILD));
map.put(new Actions(Actions.RETURN));
BasicLookAndFeel.installAudioActionMap(map);
|
private static javax.swing.MenuElement | nextEnabledChild(javax.swing.MenuElement[] e, int fromIndex, int toIndex)
for (int i=fromIndex; i<=toIndex; i++) {
if (e[i] != null) {
Component comp = e[i].getComponent();
if (comp != null && comp.isEnabled() && comp.isVisible()) {
return e[i];
}
}
}
return null;
|
private static javax.swing.MenuElement | previousEnabledChild(javax.swing.MenuElement[] e, int fromIndex, int toIndex)
for (int i=fromIndex; i>=toIndex; i--) {
if (e[i] != null) {
Component comp = e[i].getComponent();
if (comp != null && comp.isEnabled() && comp.isVisible()) {
return e[i];
}
}
}
return null;
|
protected void | uninstallDefaults()
LookAndFeel.uninstallBorder(popupMenu);
|
protected void | uninstallKeyboardActions()
SwingUtilities.replaceUIActionMap(popupMenu, null);
SwingUtilities.replaceUIInputMap(popupMenu,
JComponent.WHEN_IN_FOCUSED_WINDOW, null);
|
protected void | uninstallListeners()
if (popupMenuListener != null) {
popupMenu.removePopupMenuListener(popupMenuListener);
}
if (menuKeyListener != null) {
popupMenu.removeMenuKeyListener(menuKeyListener);
}
if(mouseGrabber != null) {
MenuSelectionManager msm = MenuSelectionManager.defaultManager();
msm.removeChangeListener(mouseGrabber);
mouseGrabber.ungrabWindow();
mouseGrabber = null;
}
|
public void | uninstallUI(javax.swing.JComponent c)
uninstallDefaults();
uninstallListeners();
uninstallKeyboardActions();
popupMenu = null;
|