本文整理汇总了Java中javax.swing.JDialog.getRootPane方法的典型用法代码示例。如果您正苦于以下问题:Java JDialog.getRootPane方法的具体用法?Java JDialog.getRootPane怎么用?Java JDialog.getRootPane使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JDialog
的用法示例。
在下文中一共展示了JDialog.getRootPane方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import javax.swing.JDialog; //导入方法依赖的package包/类
public void open(JComponent progressComponent) {
holder.add(progressComponent, BorderLayout.CENTER);
DialogDescriptor dd = new DialogDescriptor(
this,
NbBundle.getMessage(ProgressPanel.class, "MSG_PleaseWait"),
true,
new Object[0],
DialogDescriptor.NO_OPTION,
DialogDescriptor.DEFAULT_ALIGN,
null,
null,
true);
dialog = DialogDisplayer.getDefault().createDialog(dd);
if (dialog instanceof JDialog) {
JDialog jDialog = ((JDialog)dialog);
jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
JRootPane rootPane = jDialog.getRootPane();
rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NOI18N
rootPane.getActionMap().put("cancel", new AbstractAction() { // NOI18N
public void actionPerformed(ActionEvent event) {
if (cancelButton.isEnabled()) {
cancelButton.doClick();
}
}
});
}
dialog.setResizable(false);
dialog.setVisible(true);
}
示例2: open
import javax.swing.JDialog; //导入方法依赖的package包/类
public void open(JComponent progressComponent) {
holder.add(progressComponent, BorderLayout.CENTER);
DialogDescriptor dd = new DialogDescriptor(
this,
NbBundle.getMessage (ProgressPanel.class, "MSG_PleaseWait"),
true,
new Object[0],
DialogDescriptor.NO_OPTION,
DialogDescriptor.DEFAULT_ALIGN,
null,
null,
true);
dialog = DialogDisplayer.getDefault().createDialog(dd);
if (dialog instanceof JDialog) {
JDialog jDialog = ((JDialog)dialog);
jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
JRootPane rootPane = jDialog.getRootPane();
rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NOI18N
rootPane.getActionMap().put("cancel", new AbstractAction() { // NOI18N
public void actionPerformed(ActionEvent event) {
if (cancelButton.isEnabled()) {
cancelButton.doClick();
}
}
});
}
dialog.setResizable(false);
dialog.setVisible(true);
}
示例3: JDialogWindowListener
import javax.swing.JDialog; //导入方法依赖的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));
}