本文整理汇总了Java中javax.swing.JDialog.setModalityType方法的典型用法代码示例。如果您正苦于以下问题:Java JDialog.setModalityType方法的具体用法?Java JDialog.setModalityType怎么用?Java JDialog.setModalityType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JDialog
的用法示例。
在下文中一共展示了JDialog.setModalityType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showConfigurationDialog
import javax.swing.JDialog; //导入方法依赖的package包/类
private void showConfigurationDialog(ITopologyGenerator generator) {
JDialog dialog = new JDialog();
dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
dialog.setLayout(new BorderLayout());
dialog.setTitle(generator.getName());
dialog.add(generator.getConfigurationDialog(), BorderLayout.CENTER);
Rectangle tbounds = this.getBounds();
Rectangle bounds = new Rectangle();
bounds.setSize(generator.getConfigurationDialog().getPreferredSize());
bounds.x = (int) (tbounds.x + 0.5 * tbounds.width - 0.5 * bounds.width);
bounds.y = (int) (tbounds.y + 0.5 * tbounds.height - 0.5 * bounds.height);
dialog.setBounds(bounds);
dialog.setResizable(false);
dialog.setVisible(true);
}
示例2: createAndShowTestDialog
import javax.swing.JDialog; //导入方法依赖的package包/类
private static void createAndShowTestDialog(String description,
String failMessage, Runnable action) {
final JDialog dialog = new JDialog();
dialog.setTitle("Test: " + (++testCount));
dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
JTextArea textArea = new JTextArea(description);
textArea.setEditable(false);
final JButton testButton = new JButton("Print Table");
final JButton passButton = new JButton("PASS");
passButton.setEnabled(false);
passButton.addActionListener((e) -> {
dialog.dispose();
});
final JButton failButton = new JButton("FAIL");
failButton.setEnabled(false);
failButton.addActionListener((e) -> {
throw new RuntimeException(failMessage);
});
testButton.addActionListener((e) -> {
testButton.setEnabled(false);
action.run();
passButton.setEnabled(true);
failButton.setEnabled(true);
});
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(textArea, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel(new FlowLayout());
buttonPanel.add(testButton);
buttonPanel.add(passButton);
buttonPanel.add(failButton);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
dialog.add(mainPanel);
dialog.pack();
dialog.setVisible(true);
}