javax.swing.JDialog#setDefaultCloseOperation ( )源码实例Demo

下面列出了javax.swing.JDialog#setDefaultCloseOperation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gameserver   文件: StrengthTestService.java
public StrengthTestService( 
		StrengthTestConfig config, MyTablePanel tablePanel) {
	this.model = model;
	this.config = config;
	this.count = config.getMaxTry();
	this.tablePanel = tablePanel;
	
	panel = new JXPanel();
	panel.setLayout(new MigLayout("wrap 1"));
	panel.add(label, "growx, wrap 20");
	panel.add(progressBar, "grow, push");
	
	dialog = new JDialog();
	dialog.add(panel);
	dialog.setSize(300, 120);
	Point p = WindowUtils.getPointForCentering(dialog);
	dialog.setLocation(p);
	dialog.setModal(true);
	dialog.setResizable(false);
	dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
			
	model = new StrengthTestResultModel();
	tablePanel.setTableModel(model);
}
 
源代码2 项目: jmg   文件: LoadingWindow.java
public static void showLoadingWindow()
{
	try {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	} catch (Exception e) {
	} 
	JOptionPane pane = new JOptionPane("Загрузка. Пожалуйста, подождите...", JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[]{}, null);
	
	LOADING_PANE = new JDialog();
	LOADING_PANE.setModal(false);

	LOADING_PANE.setContentPane(pane);

	LOADING_PANE.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

	LOADING_PANE.setLocation(100, 200);
	LOADING_PANE.pack();
	LOADING_PANE.setVisible(true);
}
 
源代码3 项目: stendhal   文件: ProgressLog.java
/**
 * Create a new ProgressLog.
 *
 * @param name name of the window
 */
ProgressLog(String name) {
	window = new JDialog(j2DClient.get().getMainFrame(), name);

	tabs = new JTabbedPane();
	tabs.setPreferredSize(new Dimension(PAGE_WIDTH, PAGE_HEIGHT));
	tabs.addChangeListener(new TabChangeListener());

	WindowUtils.closeOnEscape(window);
	window.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	window.add(tabs);
	window.pack();
	WindowUtils.watchFontSize(window);
	WindowUtils.trackLocation(window, "travel_log", true);

	WtWindowManager.getInstance().registerSettingChangeListener("ui.logfont",
			new SettingChangeAdapter("ui.logfont", FONT_NAME) {
		@Override
		public void changed(String newValue) {
			fontName = newValue;
			for (Page page : pages) {
				page.setFontName(newValue);
			}
		}
	});
}
 
源代码4 项目: gameserver   文件: BackupMongoConfigService.java
public BackupMongoConfigService(File backupDir, String[] backupCollections) {
	this.backupDir = backupDir;
	this.backupDir.getParentFile().mkdirs();
	
	panel = new JXPanel();
	panel.setLayout(new MigLayout("wrap 1"));
	panel.add(label, "growx, wrap 20");
	panel.add(progressBar, "grow, push");
	
	dialog = new JDialog();
	dialog.add(panel);
	dialog.setSize(300, 120);
	Point p = WindowUtils.getPointForCentering(dialog);
	dialog.setLocation(p);
	dialog.setModal(true);
	dialog.setResizable(false);
	dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	
	this.backupCollections = backupCollections;
}
 
源代码5 项目: opt4j   文件: Opt4JAbout.java
@Override
public JDialog getDialog(ApplicationFrame frame) {
	JDialog dialog = new JDialog(frame, "About Opt4J", true);
	dialog.setBackground(Color.WHITE);
	dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	dialog.setResizable(false);

	Opt4JAbout content = new Opt4JAbout();
	content.startup();
	dialog.add(content);

	Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
	Dimension window = dialog.getPreferredSize();
	dialog.setLocation((screen.width - window.width) / 2, (screen.height - window.height) / 2);

	return dialog;
}
 
源代码6 项目: openjdk-jdk9   文件: bug6544309.java
private void setupUI() {
    dialog = new JDialog();
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setSize(200, 100);
    dialog.setLocationRelativeTo(null);
    dialog.setVisible(true);

    JPopupMenu popup = new JPopupMenu();
    popup.add(new JMenuItem("one"));
    JMenuItem two = new JMenuItem("two");
    two.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            passed = true;
        }
    });
    popup.add(two);
    popup.add(new JMenuItem("three"));
    popup.show(dialog, 50, 50);
}
 
源代码7 项目: gameserver   文件: RedisRefreshService.java
public RedisRefreshService(RedisTreeTableModel treeTableModel, String host, int port) {
	this.treeTableModel = treeTableModel;
	this.host = host;
	this.port = port;
	
	panel = new JXPanel();
	panel.setLayout(new MigLayout("wrap 1"));
	panel.add(label, "growx, wrap 20");
	panel.add(progressBar, "grow, push");

	dialog = new JDialog();
	dialog.add(panel);
	dialog.setSize(300, 120);
	Point p = WindowUtils.getPointForCentering(dialog);
	dialog.setLocation(p);
	dialog.setModal(true);
	dialog.setResizable(false);
	dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
}
 
源代码8 项目: hortonmachine   文件: GeopaparazziViewer.java
private void openImageInDialog( long imageId, String imageName, File dbFile, boolean doOriginalSize ) throws Exception {
    BufferedImage bufferedImage = readImageToBufferedImage(imageId, dbFile, doOriginalSize);

    if (bufferedImage != null) {
        JDialog f = new JDialog();
        f.add(new JLabel(new ImageIcon(bufferedImage)), BorderLayout.CENTER);
        f.setTitle(imageName);
        f.pack();
        f.setSize(bufferedImage.getWidth(), bufferedImage.getHeight());
        f.setLocationRelativeTo(null); // Center on screen
        f.setVisible(true);
        f.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    }
}
 
源代码9 项目: netbeans   文件: ProgressPanel.java
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
            @Override
            public void actionPerformed(ActionEvent event) {
                if (cancelButton.isEnabled()) {
                    cancelButton.doClick();
                }
            }
        });
    }
    dialog.setResizable(false);
    dialog.setVisible(true);
}
 
源代码10 项目: RipplePower   文件: SwingUtils.java
static public JDialog addDialogWindow(Frame mainWindow, Component jpanel, String title) {
	JDialog dialog = new JDialog(mainWindow, title, true);
	dialog.getContentPane().setLayout(new BorderLayout());
	dialog.getContentPane().add(jpanel, BorderLayout.CENTER);
	dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	dialog.pack();
	dialog.setLocationRelativeTo(mainWindow);
	dialog.setSize(jpanel.getPreferredSize());
	dialog.setVisible(true);
	return dialog;
}
 
源代码11 项目: snap-desktop   文件: ColorChooserPanel.java
protected Color showMoreColorsDialog() {
    JColorChooser colorChooser = new JColorChooser(getSelectedColor());
    AbstractColorChooserPanel[] oldChooserPanels = colorChooser.getChooserPanels();
    AbstractColorChooserPanel[] newChooserPanels = new AbstractColorChooserPanel[oldChooserPanels.length + 1];
    System.arraycopy(oldChooserPanels, 0, newChooserPanels, 1, oldChooserPanels.length);
    newChooserPanels[0] = new MyAbstractColorChooserPanel();
    colorChooser.setChooserPanels(newChooserPanels);
    ColorTracker colorTracker = new ColorTracker(colorChooser);
    JDialog dialog = JColorChooser.createDialog(this, "Select Colour", true, colorChooser, colorTracker, null);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setVisible(true);
    return colorTracker.getColor();
}
 
源代码12 项目: gameserver   文件: DownloadIconsService.java
@Override
protected void process(List<Integer> chunks) {
	if ( stage == Stage.GET_NUM_OF_ICONS ) {
		panel = new JXPanel();
		panel.setLayout(new MigLayout("wrap 1"));
		panel.add(label, "growx, wrap 20");
		panel.add(progressBar, "grow, push");
		
		dialog = new JDialog();
		dialog.add(panel);
		dialog.setSize(300, 120);
		Point p = WindowUtils.getPointForCentering(dialog);
		dialog.setLocation(p);
		dialog.setModal(true);
		dialog.setResizable(false);
		dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		dialog.setVisible(true);
		
		label.setText("正在获取图标列表...");
		label.setFont(MainFrame.BIG_FONT);
		progressBar.setIndeterminate(true);
	} else if ( stage == Stage.GOT_NUM_OF_ICONS ) {
		label.setFont(MainFrame.BIG_FONT);
		label.setText("总图标数量: " + icons.size());
		label.repaint();
		progressBar.setIndeterminate(false);
		progressBar.setMinimum(0);
		progressBar.setMaximum(icons.size());
		progressBar.setStringPainted(true);
	} else if ( stage == Stage.DOWNLOAD_ICONS ) {
		if ( chunks != null && chunks.size()>0 ) {
			int percent = chunks.get(chunks.size()-1);
			progressBar.setValue(percent);
		}
	} else if ( stage == Stage.INITIAL_EQUIPS ) {
		label.setText("正在初始化装备数据...");
		progressBar.setIndeterminate(true);
	}
}
 
源代码13 项目: swift-explorer   文件: MainPanel.java
public void onProgressButton ()
{    	
	if (progressPanel.isShowing())
		return ;

	JDialog dlg = new JDialog (owner) ;
	dlg.setContentPane(progressPanel);
	dlg.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
	dlg.setTitle(getLocalizedString("Progress"));
	dlg.pack();
	center (dlg) ;
	dlg.setVisible(true);
}
 
源代码14 项目: pgptool   文件: CreateKeyView.java
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.createPgpKey"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	UiUtils.centerWindow(ret, owner);
	return ret;
}
 
源代码15 项目: sldeditor   文件: SortByPanelTest.java
/** Test method for {@link com.sldeditor.ui.detail.config.sortby.SortByPanel#SortByPanel()}. */
@Test
public void testSortByPanel() {
    TestSortByUpdate output = new TestSortByUpdate();

    TestSortByPanel panel = new TestSortByPanel(output, 6);

    JDialog dialog = new JDialog();
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setModal(true);
    dialog.add(panel, BorderLayout.CENTER);
    dialog.pack();
    dialog.setLocation(200, 200);
    dialog.setTitle("SortBy Test Dialog");

    List<String> fieldList = Arrays.asList("Field1", "Field2", "Field3", "Field4", "Field5");
    String selectedFieldList = "Field2 D, Field4 A";
    panel.populateFieldNames(fieldList);
    panel.setText("");
    panel.setText(selectedFieldList);

    assertEquals(selectedFieldList, panel.getText());
    int[] selectedIndexes = new int[1];
    selectedIndexes[0] = 1;

    panel.selectDestination(selectedIndexes);
    panel.moveDestinationUp();
    assertEquals("Field4 A, Field2 D", output.text);
    panel.moveDestinationUp();
    assertEquals("Field4 A, Field2 D", output.text);

    panel.moveDestinationDown();
    assertEquals("Field2 D, Field4 A", output.text);
    panel.moveDestinationDown();
    assertEquals("Field2 D, Field4 A", output.text);

    // Move source to destination
    int[] selectedSourceIndexes = new int[2];
    selectedSourceIndexes[0] = 1;
    selectedSourceIndexes[1] = 2;
    panel.selectSource(selectedSourceIndexes);

    panel.moveSrcToDestination();
    assertEquals("Field2 D, Field4 A, Field3 A, Field5 A", output.text);

    // Move destination to source
    selectedIndexes[0] = 0;

    panel.selectDestination(selectedIndexes);
    panel.moveDestinationToSource();
    assertEquals("Field4 A, Field3 A, Field5 A", output.text);

    panel.setSortOrder(1, false);
    assertEquals("Field4 A, Field3 D, Field5 A", output.text);

    panel.setSortOrder(1, true);
    assertEquals("Field4 A, Field3 A, Field5 A", output.text);

    // Remove field from data source
    fieldList = Arrays.asList("Field1", "Field2", "Field3", "Field4");
    panel.populateFieldNames(fieldList);
    assertEquals("Field4 A, Field3 A", output.text);

    // Increase code coverage
    panel.dataSourceLoaded(GeometryTypeEnum.POINT, false);
    panel.dataSourceAboutToUnloaded(null);

    panel = new TestSortByPanel(null, 6);
    panel.sortOrderUpdated();

    // If the next is uncommented the unit test stops being unattended
    // dialog.setVisible(true);
}
 
源代码16 项目: ramus   文件: FilePlugin.java
protected int showOptionDialog(JFrame mainFrame, String message,
                               String title, String[] options, int defaultValue) {
    final IntHolder holder = new IntHolder();
    final JDialog dialog = new JDialog(mainFrame, true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    holder.value = defaultValue;
    JPanel panel = new JPanel(new BorderLayout());
    JPanel m = new JPanel(new FlowLayout());
    m.add(new JLabel(message));
    panel.add(m, BorderLayout.CENTER);
    JPanel bottom = new JPanel(new GridLayout(1, 3, 5, 7));
    int i = 0;
    for (String s : options) {
        final int r = i;
        JButton button = new JButton(new AbstractAction(s) {
            /**
             *
             */
            private static final long serialVersionUID = 7269041268620864162L;

            @Override
            public void actionPerformed(ActionEvent e) {
                holder.value = r;
                dialog.setVisible(false);
            }
        });
        i++;
        bottom.add(button);
    }
    JPanel p = new JPanel(new FlowLayout());
    p.add(bottom);

    panel.add(p, BorderLayout.SOUTH);
    JPanel pane = new JPanel(new FlowLayout());
    pane.add(panel);
    dialog.setTitle(title);
    dialog.setContentPane(pane);
    dialog.pack();
    dialog.setResizable(false);
    dialog.setLocationRelativeTo(null);
    dialog.setVisible(true);
    return holder.value;
}
 
private static void createAndShowTestDialog() {
    String description =
        " To run this test it is required to have a virtual PDF\r\n" +
        " printer or any other printer supporting A5 paper size.\r\n" +
        "\r\n" +
        " 1. Verify that NOT A5 paper size is set as default for the\r\n" +
        " printer to be used.\r\n" +
        " 2. Click on \"Start Test\" button.\r\n" +
        " 3. In the shown print dialog select the printer and click\r\n" +
        " on \"Print\" button.\r\n" +
        " 4. Verify that a page with a drawn rectangle is printed on\r\n" +
        " a paper of A5 size which is (5.8 x 8.3 in) or\r\n" +
        " (148 x 210 mm).\r\n" +
        "\r\n" +
        " If the printed page size is correct, click on \"PASS\"\r\n" +
        " button, otherwise click on \"FAIL\" button.";

    final JDialog dialog = new JDialog();
    dialog.setTitle("WrongPaperPrintingTest");
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            dialog.dispose();
            fail("Main dialog was closed.");
        }
    });

    final JLabel testTimeoutLabel = new JLabel(String.format(
        "Test timeout: %s", convertMillisToTimeStr(testTimeout)));
    final long startTime = System.currentTimeMillis();
    final Timer timer = new Timer(0, null);
    timer.setDelay(1000);
    timer.addActionListener((e) -> {
        int leftTime = testTimeout - (int)(System.currentTimeMillis() - startTime);
        if ((leftTime < 0) || testFinished) {
            timer.stop();
            dialog.dispose();
        }
        testTimeoutLabel.setText(String.format(
            "Test timeout: %s", convertMillisToTimeStr(leftTime)));
    });
    timer.start();

    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);

    final JButton testButton = new JButton("Start Test");
    final JButton passButton = new JButton("PASS");
    final JButton failButton = new JButton("FAIL");
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        new Thread(() -> {
            try {
                doTest();

                SwingUtilities.invokeLater(() -> {
                    passButton.setEnabled(true);
                    failButton.setEnabled(true);
                });
            } catch (Throwable t) {
                t.printStackTrace();
                dialog.dispose();
                fail("Exception occurred in a thread executing the test.");
            }
        }).start();
    });
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
        pass();
    });
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        dialog.dispose();
        fail("Size of a printed page is wrong.");
    });

    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel labelPanel = new JPanel(new FlowLayout());
    labelPanel.add(testTimeoutLabel);
    mainPanel.add(labelPanel, BorderLayout.NORTH);
    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);
}
 
源代码18 项目: openjdk-jdk8u   文件: TestTextPosInPrint.java
private static void createAndShowTestDialog() {
    String description =
        " 1. Click on \"Start Test\" button.\r\n" +
        " 2. Multiple strings will be displayed on console.\r\n" +
        " 3. A print dialog will be shown. Select any printer to print. " +
        "\r\n" +
        " If the printed output of the strings are same without any alignment issue, click on \"PASS\"\r\n" +
        " button, otherwise click on \"FAIL\" button.";

    final JDialog dialog = new JDialog();
    dialog.setTitle("SaveFileWithoutPrinter");
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            dialog.dispose();
            fail("Main dialog was closed.");
        }
    });

    final JLabel testTimeoutLabel = new JLabel(String.format(
        "Test timeout: %s", convertMillisToTimeStr(testTimeout)));
    final long startTime = System.currentTimeMillis();
    final Timer timer = new Timer(0, null);
    timer.setDelay(1000);
    timer.addActionListener((e) -> {
        int leftTime = testTimeout - (int) (System.currentTimeMillis() - startTime);
        if ((leftTime < 0) || testFinished) {
            timer.stop();
            dialog.dispose();
        }
        testTimeoutLabel.setText(String.format(
            "Test timeout: %s", convertMillisToTimeStr(leftTime)));
    });
    timer.start();

    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);

    final JButton testButton = new JButton("Start Test");
    final JButton passButton = new JButton("PASS");
    final JButton failButton = new JButton("FAIL");
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        new Thread(() -> {
            try {
                doTest();

                SwingUtilities.invokeLater(() -> {
                    passButton.setEnabled(true);
                    failButton.setEnabled(true);
                });
            } catch (Throwable t) {
                t.printStackTrace();
                dialog.dispose();
                fail("Exception occurred in a thread executing the test.");
            }
        }).start();
    });
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
        pass();
    });
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        dialog.dispose();
        fail("Printed texts are not aligned as shown in console");
    });

    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel labelPanel = new JPanel(new FlowLayout());
    labelPanel.add(testTimeoutLabel);
    mainPanel.add(labelPanel, BorderLayout.NORTH);
    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);
}
 
源代码19 项目: libreveris   文件: LicenseCompanion.java
@Override
protected void doInstall ()
        throws Exception
{
    // When running without UI, we assume license is accepted
    if (!Installer.hasUI()) {
        return;
    }

    // User choice (must be an output, yet final)
    final boolean[] isOk = new boolean[1];

    final String yes = "Yes";
    final String no = "No";
    final String browse = "View License";
    final JOptionPane optionPane = new JOptionPane(
            "Do you agree to license " + LICENSE_NAME + "?",
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_CANCEL_OPTION,
            null,
            new Object[]{yes, no, browse},
            yes);
    final String frameTitle = "End User License Agreement";
    final JDialog dialog = new JDialog(
            Installer.getFrame(),
            frameTitle,
            true);
    dialog.setContentPane(optionPane);

    // Prevent dialog closing
    dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

    optionPane.addPropertyChangeListener(
            new PropertyChangeListener()
    {
        @Override
        public void propertyChange (PropertyChangeEvent e)
        {
            String prop = e.getPropertyName();

            if (dialog.isVisible()
                && (e.getSource() == optionPane)
                && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                Object option = optionPane.getValue();
                logger.debug("option: {}", option);

                if (option == yes) {
                    isOk[0] = true;
                    dialog.setVisible(false);
                    dialog.dispose();
                } else if (option == no) {
                    isOk[0] = false;
                    dialog.setVisible(false);
                    dialog.dispose();
                } else if (option == browse) {
                    logger.info(
                            "Launching browser on {}",
                            LICENSE_URL);
                    showLicense();
                    optionPane.setValue(
                            JOptionPane.UNINITIALIZED_VALUE);
                } else {
                }
            }
        }
    });

    dialog.pack();
    dialog.setLocationRelativeTo(Installer.getFrame());
    dialog.setVisible(true);

    logger.debug("OK: {}", isOk[0]);

    if (!isOk[0]) {
        throw new LicenseDeclinedException();
    }
}
 
源代码20 项目: snap-desktop   文件: AssistantPane.java
/**
 * Creates a new {@code AssistantPane}.
 *
 * @param parent The parent window.
 * @param title  The title of the dialog.
 */
public AssistantPane(Window parent, String title) {

    pageStack = new ArrayDeque<AssistantPage>();

    prevAction = new PrevAction();
    nextAction = new NextAction();
    finishAction = new FinishAction();
    cancelAction = new CancelAction();
    helpAction = new HelpAction();

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 2));
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    buttonPanel.add(new JButton(prevAction));
    final JButton nextButton = new JButton(nextAction);
    buttonPanel.add(nextButton);
    buttonPanel.add(new JButton(finishAction));
    buttonPanel.add(new JButton(cancelAction));
    buttonPanel.add(new JButton(helpAction));

    titleLabel = new JLabel();
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 14.0f));
    titleLabel.setHorizontalAlignment(JLabel.RIGHT);
    titleLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    titleLabel.setForeground(Color.WHITE);

    JPanel titlePanel = new JPanel(new BorderLayout());
    titlePanel.setBackground(titlePanel.getBackground().darker());
    titlePanel.add(titleLabel, BorderLayout.CENTER);

    pagePanel = new JPanel(new BorderLayout());
    pagePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    dialog = new JDialog(parent, title, Dialog.ModalityType.APPLICATION_MODAL);
    dialog.getContentPane().add(titlePanel, BorderLayout.NORTH);
    dialog.getContentPane().add(pagePanel, BorderLayout.CENTER);
    dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dialog.getRootPane().setDefaultButton(nextButton);
    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            cancelAction.cancel();
        }
    });
}