本文整理匯總了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));
}