当前位置: 首页>>代码示例>>Java>>正文


Java JPanel.getInputMap方法代码示例

本文整理汇总了Java中javax.swing.JPanel.getInputMap方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.getInputMap方法的具体用法?Java JPanel.getInputMap怎么用?Java JPanel.getInputMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JPanel的用法示例。


在下文中一共展示了JPanel.getInputMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDialog

import javax.swing.JPanel; //导入方法依赖的package包/类
private JDialog createDialog(Component parent) {
    Frame frame = parent instanceof Frame ? (Frame) parent
            : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
    JDialog dialog = new JDialog(frame, getMessage("SelectFont"), true);

    Action okAction = new DialogOKAction(dialog);
    Action cancelAction = new DialogCancelAction(dialog);

    JButton okButton = new JButton(okAction);
    okButton.setFont(DEFAULT_FONT);
    JButton cancelButton = new JButton(cancelAction);
    cancelButton.setFont(DEFAULT_FONT);

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(2, 1));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));

    ActionMap actionMap = buttonsPanel.getActionMap();
    actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
    actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
    InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));

    JPanel dialogEastPanel = new JPanel();
    dialogEastPanel.setLayout(new BorderLayout());
    dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);

    dialog.getContentPane().add(this, BorderLayout.CENTER);
    dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
    dialog.pack();
    dialog.setLocationRelativeTo(frame);
    return dialog;
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:37,代码来源:FontChooser.java

示例2: createDialog

import javax.swing.JPanel; //导入方法依赖的package包/类
protected JDialog createDialog(Component parent) {
	Frame frame = parent instanceof Frame ? (Frame) parent
			: (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
	JDialog dialog = new JDialog(frame, ("Select Font"), true);

	Action okAction = new DialogOKAction(dialog);
	Action cancelAction = new DialogCancelAction(dialog);

	JButton okButton = new JButton(okAction);
	okButton.setFont(DEFAULT_FONT);
	JButton cancelButton = new JButton(cancelAction);
	cancelButton.setFont(DEFAULT_FONT);

	JPanel buttonsPanel = new JPanel();
	buttonsPanel.setLayout(new GridLayout(2, 1));
	buttonsPanel.add(okButton);
	buttonsPanel.add(cancelButton);
	buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));

	ActionMap actionMap = buttonsPanel.getActionMap();
	actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
	actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
	InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
	inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
	inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));

	JPanel dialogEastPanel = new JPanel();
	dialogEastPanel.setLayout(new BorderLayout());
	dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);

	dialog.getContentPane().add(this, BorderLayout.CENTER);
	dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
	dialog.pack();
	dialog.setLocationRelativeTo(frame);
	return dialog;
}
 
开发者ID:KevinPriv,项目名称:Luyten4Forge,代码行数:37,代码来源:JFontChooser.java

示例3: createDialog

import javax.swing.JPanel; //导入方法依赖的package包/类
protected JDialog createDialog(Component parent)
{
    Frame frame = parent instanceof Frame ? (Frame) parent
        : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
    JDialog dialog = new JDialog(frame, Editor.fromConfiguracao.getValor("Inspector.obj.font.selfonte"), true);

    Action okAction = new DialogOKAction(dialog);
    Action cancelAction = new DialogCancelAction(dialog);

    JButton okButton = new JButton(okAction);
    okButton.setFont(DEFAULT_FONT);
    JButton cancelButton = new JButton(cancelAction);
    cancelButton.setFont(DEFAULT_FONT);

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(2, 1));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));

    ActionMap actionMap = buttonsPanel.getActionMap();
    actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
    actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
    InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));

    JPanel dialogEastPanel = new JPanel();
    dialogEastPanel.setLayout(new BorderLayout());
    dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);

    dialog.getContentPane().add(this, BorderLayout.CENTER);
    dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
    dialog.pack();
    dialog.setLocationRelativeTo(frame);
    return dialog;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:38,代码来源:JFontChooser.java


注:本文中的javax.swing.JPanel.getInputMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。