下面列出了javax.swing.SwingUtilities#replaceUIActionMap ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Creates new form CompareResultImages
*/
public CompareResultImages() {
initComponents();
toReviewList.setModel(new DefaultListModel());
fillList();
setSize(800, 600);
setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
actualImage.setStretch(false);
referenceImage.setStretch(false);
acceptAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control D"));
InputMap keyMap = new ComponentInputMap(acceptButton);
keyMap.put(KeyStroke.getKeyStroke("control D"), "accept");
ActionMap actionMap = new ActionMapUIResource();
actionMap.put("accept", acceptAction);
SwingUtilities.replaceUIActionMap(acceptButton, actionMap);
SwingUtilities.replaceUIInputMap(acceptButton, JComponent.WHEN_IN_FOCUSED_WINDOW, keyMap);
}
/**
* Invoked as part from the boilerplate install block.
*/
protected void installKeyboardActions(mxGraphComponent graphComponent)
{
InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
SwingUtilities.replaceUIInputMap(graphComponent,
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);
inputMap = getInputMap(JComponent.WHEN_FOCUSED);
SwingUtilities.replaceUIInputMap(graphComponent,
JComponent.WHEN_FOCUSED, inputMap);
SwingUtilities.replaceUIActionMap(graphComponent, createActionMap());
}
protected void installKeyboardActions() {
InputMap inputMap = (InputMap)UIManager.get("TaskPaneGroup.focusInputMap");
if (inputMap != null) {
SwingUtilities.replaceUIInputMap(
group,
JComponent.WHEN_FOCUSED,
inputMap);
}
ActionMap map = getActionMap();
if (map != null) {
SwingUtilities.replaceUIActionMap(group, map);
}
}
@Override
protected void installListeners(JFileChooser fc) {
super.installListeners(fc);
ActionMap actionMap = getActions();
SwingUtilities.replaceUIActionMap(fc, actionMap);
}
protected void uninstallKeyboardActions() {
SwingUtilities.replaceUIActionMap(lizziePane, null);
SwingUtilities.replaceUIInputMap(
lizziePane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
}
protected void installKeyboardActions() {
ActionMap map = getActionMap();
if (map != null) {
SwingUtilities.replaceUIActionMap(tipPane, map);
}
}
@Override
protected void installKeyboardActions() {
InputMap km = getMyInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, km);
km = getMyInputMap(JComponent.WHEN_FOCUSED);
SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, km);
ActionMap am = createMyActionMap();
SwingUtilities.replaceUIActionMap(tabPane, am);
tabScroller.scrollForwardButton.setAction(am.get("scrollTabsForwardAction"));
tabScroller.scrollBackwardButton.setAction(am.get("scrollTabsBackwardAction"));
}
@Override
protected void uninstallKeyboardActions() {
SwingUtilities.replaceUIActionMap(tabPane, null);
SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, null);
}
protected void uninstallKeyboardActions()
{
SwingUtilities.replaceUIInputMap(terminal, JComponent.WHEN_FOCUSED, null);
SwingUtilities.replaceUIActionMap(terminal, null);
}