| Method from javax.swing.plaf.basic.BasicMenuUI Detail: |
protected ChangeListener createChangeListener(JComponent c) {
return null;
}
|
protected MenuDragMouseListener createMenuDragMouseListener(JComponent c) {
return getHandler();
}
|
protected MenuKeyListener createMenuKeyListener(JComponent c) {
return (MenuKeyListener)getHandler();
}
|
protected MenuListener createMenuListener(JComponent c) {
return null;
}
|
protected MouseInputListener createMouseInputListener(JComponent c) {
return getHandler();
}
|
protected PropertyChangeListener createPropertyChangeListener(JComponent c) {
return getHandler();
}
|
public static ComponentUI createUI(JComponent x) {
return new BasicMenuUI();
}
|
BasicMenuItemUI.Handler getHandler() {
if (handler == null) {
handler = new Handler();
}
return handler;
}
|
public Dimension getMaximumSize(JComponent c) {
if (((JMenu)menuItem).isTopLevelMenu() == true) {
Dimension d = c.getPreferredSize();
return new Dimension(d.width, Short.MAX_VALUE);
}
return null;
}
|
protected String getPropertyPrefix() {
return "Menu";
}
|
protected void installDefaults() {
super.installDefaults();
updateDefaultBackgroundColor();
((JMenu)menuItem).setDelay(200);
crossMenuMnemonic = UIManager.getBoolean("Menu.crossMenuMnemonic");
}
|
protected void installKeyboardActions() {
super.installKeyboardActions();
updateMnemonicBinding();
}
|
void installLazyActionMap() {
LazyActionMap.installLazyActionMap(menuItem, BasicMenuUI.class,
getPropertyPrefix() + ".actionMap");
}
|
protected void installListeners() {
super.installListeners();
if (changeListener == null)
changeListener = createChangeListener(menuItem);
if (changeListener != null)
menuItem.addChangeListener(changeListener);
if (menuListener == null)
menuListener = createMenuListener(menuItem);
if (menuListener != null)
((JMenu)menuItem).addMenuListener(menuListener);
}
|
static void loadActionMap(LazyActionMap map) {
BasicMenuItemUI.loadActionMap(map);
map.put(new Actions(Actions.SELECT, null, true));
}
|
protected void setupPostTimer(JMenu menu) {
Timer timer = new Timer(menu.getDelay(), new Actions(
Actions.SELECT, menu,false));
timer.setRepeats(false);
timer.start();
}
|
protected void uninstallDefaults() {
menuItem.setArmed(false);
menuItem.setSelected(false);
menuItem.resetKeyboardActions();
super.uninstallDefaults();
}
|
protected void uninstallKeyboardActions() {
super.uninstallKeyboardActions();
lastMnemonic = 0;
}
|
protected void uninstallListeners() {
super.uninstallListeners();
if (changeListener != null)
menuItem.removeChangeListener(changeListener);
if (menuListener != null)
((JMenu)menuItem).removeMenuListener(menuListener);
changeListener = null;
menuListener = null;
handler = null;
}
|
void updateMnemonicBinding() {
int mnemonic = menuItem.getModel().getMnemonic();
int[] shortcutKeys = (int[])DefaultLookup.get(menuItem, this,
"Menu.shortcutKeys");
if (shortcutKeys == null) {
shortcutKeys = new int[] {KeyEvent.ALT_MASK};
}
if (mnemonic == lastMnemonic) {
return;
}
InputMap windowInputMap = SwingUtilities.getUIInputMap(
menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW);
if (lastMnemonic != 0 && windowInputMap != null) {
for (int i=0; i< shortcutKeys.length; i++) {
windowInputMap.remove(KeyStroke.getKeyStroke
(lastMnemonic, shortcutKeys[i], false));
}
}
if (mnemonic != 0) {
if (windowInputMap == null) {
windowInputMap = createInputMap(JComponent.
WHEN_IN_FOCUSED_WINDOW);
SwingUtilities.replaceUIInputMap(menuItem, JComponent.
WHEN_IN_FOCUSED_WINDOW, windowInputMap);
}
for (int i=0; i< shortcutKeys.length; i++) {
windowInputMap.put(KeyStroke.getKeyStroke(mnemonic,
shortcutKeys[i], false),
"selectMenu");
}
}
lastMnemonic = mnemonic;
}
|