本文整理汇总了Java中javax.swing.JRootPane.getInputMap方法的典型用法代码示例。如果您正苦于以下问题:Java JRootPane.getInputMap方法的具体用法?Java JRootPane.getInputMap怎么用?Java JRootPane.getInputMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JRootPane
的用法示例。
在下文中一共展示了JRootPane.getInputMap方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uninstallOperation
import javax.swing.JRootPane; //导入方法依赖的package包/类
/**
* Removes an operation installed in the specified frame for the specified
* keystroke and condition.
*
* @param frame
* The frame from which the keybind is to be uninstalled.
* @param condition
* When should this keybind be activated.
* Either {@link JComponent#WHEN_FOCUSED}, {@link JComponent#WHEN_IN_FOCUSED_WINDOW}, or
* {@link JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}.
* @param keyStroke
* The keystroke used to activate the keybind
*/
public static void uninstallOperation(
final RootPaneContainer frame,
final int condition,
final KeyStroke keyStroke )
{
JRootPane root = frame.getRootPane();
InputMap inputMap = root.getInputMap( condition );
InputMap parentMap = inputMap.getParent();
// Temporarily remove the parent input map, so that we don't receive the
// action key from the parent's input map if the current input map has
// no action key bound to the key stroke.
inputMap.setParent( null );
Object actionKey = root.getInputMap( condition ).get( keyStroke );
if ( actionKey == null )
throw new OperationNotInstalledException( keyStroke );
root.getInputMap( condition ).remove( keyStroke );
root.getActionMap().remove( actionKey );
inputMap.setParent( parentMap );
}
示例2: createRootPane
import javax.swing.JRootPane; //导入方法依赖的package包/类
public JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
Action action = new AbstractAction() {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent e) {
System.out.println("escaping..");
setVisible(false);
dispose();
}
};
InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(stroke, "ESCAPE");
rootPane.getActionMap().put("ESCAPE", action);
return rootPane;
}
示例3: JDialogWindowListener
import javax.swing.JRootPane; //导入方法依赖的package包/类
/**
* Constructs
*
* @param objPcontrolJFrame
* @param objPdialog
* @param bolPdispose
*/
public JDialogWindowListener(ControlJFrame objPcontrolJFrame, JDialog objPdialog, boolean bolPdispose) {
this.objGcontrolJFrame = objPcontrolJFrame;
this.objGjDialog = objPdialog;
this.bolGdispose = bolPdispose;
final JRootPane objLrootPane = objPdialog.getRootPane();
final InputMap objLinputMap = objLrootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
objLinputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), Constants.strS_ENGINE_ESCAPE_ACTION);
objLrootPane.getActionMap().put(Constants.strS_ENGINE_ESCAPE_ACTION, new DefaultEscapeAction(this));
}
示例4: setJDialogDefaultKeys
import javax.swing.JRootPane; //导入方法依赖的package包/类
/**
* Method description
*
* @see
*/
final private void setJDialogDefaultKeys() {
final JRootPane objLrootPane = this.getRootPane();
// Enter key :
objLrootPane.setDefaultButton(this.objGoKJButton);
// Escape key :
final InputMap objLinputMap = objLrootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
objLinputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), Constants.strS_ENGINE_ESCAPE_ACTION);
objLrootPane.getActionMap().put(Constants.strS_ENGINE_ESCAPE_ACTION, new PreferencesEscapeAction(this));
}
示例5: createRootPane
import javax.swing.JRootPane; //导入方法依赖的package包/类
public JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
@SuppressWarnings("serial")
Action action = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
closeDialog();
}
};
InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(stroke, "ESCAPE");
rootPane.getActionMap().put("ESCAPE", action);
return rootPane;
}
示例6: createRootPane
import javax.swing.JRootPane; //导入方法依赖的package包/类
@Override
public JRootPane createRootPane() {
rootPane = new JRootPane();
stroke = KeyStroke.getKeyStroke("ESCAPE");
action = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
dispose();
}
};
inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(stroke, "ESCAPE");
rootPane.getActionMap().put("ESCAPE", action);
return rootPane;
}