List of usage examples for javax.swing JOptionPane DEFAULT_OPTION
int DEFAULT_OPTION
To view the source code for javax.swing JOptionPane DEFAULT_OPTION.
Click Source Link
JOptionPane
. From source file:xtrememp.update.SoftwareUpdate.java
public static void showCheckForUpdatesDialog() { checkForUpdatesDialog = new JDialog(XtremeMP.getInstance().getMainFrame(), tr("Dialog.SoftwareUpdate"), true);/* w w w.java2s .c o m*/ JPanel panel = new JPanel(new BorderLayout(0, 10)); panel.add(new JLabel(tr("Dialog.SoftwareUpdate.CheckingForUpdates")), BorderLayout.CENTER); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setPreferredSize(new Dimension(250, 20)); panel.add(progressBar, BorderLayout.SOUTH); JButton cancelButton = new JButton(tr("Button.Cancel")); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (checkForUpdatesWorker != null && !checkForUpdatesWorker.isDone()) { checkForUpdatesWorker.cancel(true); } checkForUpdatesDialog.dispose(); } }); JOptionPane optionPane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] { cancelButton }, cancelButton); checkForUpdatesDialog.setContentPane(optionPane); checkForUpdatesDialog.pack(); checkForUpdatesDialog.setResizable(false); checkForUpdatesDialog.setLocationRelativeTo(checkForUpdatesDialog.getParent()); checkForUpdatesDialog.getRootPane().setDefaultButton(cancelButton); checkForUpdatesDialog.setVisible(true); }
From source file:zxmax.tools.timerreview.gui.StartTimerWindow.java
private void storeDataAndStartTimer() { // prepare data to store Tomato tomato = new Tomato(taFocusOn.getText()); tomato.setTitle(tfTitle.getText());/*from ww w .j a v a 2 s . c o m*/ try { tomato.setDuration(Integer.parseInt(txtDurata.getText())); } catch (NumberFormatException ex) { tomato.setDuration(1); } List<String> errorMessages = validatorService.validate(tomato); int response = 0; if (errorMessages.size() > 0) { String message = StringUtils.join(errorMessages, System.getProperty("line.separator")); response = JOptionPane.showOptionDialog(null, message, I18N.getLabel(this.getClass(), "error.box.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[] {}, null); } if (response > -1) { getBasicDao().save(tomato); logger.debug(tomato.toString()); StringBuilder sb = new StringBuilder(); // sb.append((new LocalDateTime()).toString("dd/MM/yyyy HH:mm")) // .append(System.getProperty("line.separator")); sb.append(OrgModeDecorator.ORG_MODE_LEVEL_1 + I18N.getLabel(this.getClass(), TIMER_LOGGER_TITOLO)) .append(tomato.getTitle()).append(System.getProperty("line.separator")); sb.append(OrgModeDecorator.ORG_MODE_LEVEL_2 + I18N.getLabel(this.getClass(), TIMER_LOGGER_FOCUS_ON)) .append(tomato.getFocusOn()); reportLogger.info(sb.toString()); disableNewTimerMenuItem(); startCountdown(tomato); UINotificationService uiNotificationService = new UINotificationService(tomato); Register.put(UINotificationService.class, uiNotificationService); closeThisWindow(); } }
From source file:zxmax.tools.timerreview.Main.java
public static void main(final String[] args) { try {/* ww w .j av a 2 s. co m*/ JustOneLock ua = new JustOneLock(".timerreview"); if (ua.isAppActive()) { String message = I18N.getLabel(MyUncaughtExceptionHandler.class, "another.instance.already.open"); JOptionPane.showOptionDialog(null, message, I18N.getLabel(MyUncaughtExceptionHandler.class, "error.box.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[] {}, null); System.exit(0); } new Main(); } catch (Exception e) { if (e instanceof IllegalStateException) { JOptionPane.showMessageDialog(null, "controlla i file di log e contatta, se ti va, lo sviluppatore, ciao."); } LOGGER.error("", e); } }