List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:esmska.gui.AboutFrame.java
private void creditsButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_creditsButtonActionPerformed //show credits try {/*from w ww. j a va2 s . c o m*/ logger.fine("Showing credits..."); String credits = IOUtils.toString(getClass().getResourceAsStream(RES + "credits.html"), "UTF-8"); String translators = l10n.getString("Translators"); if ("translator-credits".equals(translators)) { //there are no translators mentioned translators = ""; } else { translators = translators.replaceAll("\n", "<br>\n").replaceAll("\n ", "\n "); //add hyperlinks to the Launchpad URLs translators = translators.replaceAll("(https://[^<]*)", "<a href=\"$1\">$1</a>"); } String document = MessageFormat.format(credits, l10n.getString("Credits.authors"), l10n.getString("Credits.contributors"), l10n.getString("Credits.graphics"), l10n.getString("Credits.sponsors"), l10n.getString("Credits.translators"), translators, Links.DONATORS, l10n.getString("Credits.moreDonators"), MessageFormat.format(l10n.getString("Credits.packagers"), Links.DOWNLOAD)); JTextPane tp = new JTextPane(); tp.setContentType("text/html; charset=UTF-8"); tp.setText(document); tp.setEditable(false); tp.setPreferredSize(new Dimension(450, 400)); tp.setCaretPosition(0); //make links clickable tp.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && Desktop.isDesktopSupported()) { try { logger.fine("Browsing URL: " + e.getURL()); Desktop.getDesktop().browse(e.getURL().toURI()); } catch (Exception ex) { logger.log(Level.SEVERE, "Can't browse hyperlink: " + e.getURL(), ex); } } } }); String option = l10n.getString("AboutFrame.Thank_you"); JOptionPane op = new JOptionPane(new JScrollPane(tp), JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] { option }, option); JDialog dialog = op.createDialog(this, l10n.getString("AboutFrame.Credits")); dialog.setResizable(true); dialog.pack(); dialog.setVisible(true); } catch (IOException e) { logger.log(Level.WARNING, "Could not show credits", e); } }
From source file:com.gs.obevo.util.inputreader.DialogInputReader.java
@Override public String readPassword(String promptMessage) { final JPasswordField jpf = new JPasswordField(); JOptionPane jop = new JOptionPane(jpf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = jop.createDialog(promptMessage); dialog.addComponentListener(new ComponentAdapter() { @Override/* www . j a v a 2 s . com*/ public void componentShown(ComponentEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jpf.requestFocusInWindow(); } }); } }); dialog.setVisible(true); int result = (Integer) jop.getValue(); dialog.dispose(); String password = null; if (result == JOptionPane.OK_OPTION) { password = new String(jpf.getPassword()); } if (StringUtils.isEmpty(password)) { return null; } else { return password; } }
From source file:dk.cubing.liveresults.uploader.engine.ResultsEngine.java
/** * Create preferences dialog//from ww w.j a v a 2 s .c om */ public void createAndShowPreferencesDialog() { JDialog dialog = new JDialog(frame, "Preferences"); dialog.add(new PreferencesPanel(dialog, this)); dialog.setResizable(false); dialog.pack(); dialog.setVisible(true); }
From source file:com.gs.obevo.util.inputreader.DialogInputReader.java
@Override public String readLine(String promptMessage) { final JTextField juf = new JTextField(); JOptionPane juop = new JOptionPane(juf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog userDialog = juop.createDialog(promptMessage); userDialog.addComponentListener(new ComponentAdapter() { @Override/*from w ww . j a v a2s . c o m*/ public void componentShown(ComponentEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { juf.requestFocusInWindow(); } }); } }); userDialog.setVisible(true); int uresult = (Integer) juop.getValue(); userDialog.dispose(); String userName = null; if (uresult == JOptionPane.OK_OPTION) { userName = new String(juf.getText()); } if (StringUtils.isEmpty(userName)) { return null; } else { return userName; } }
From source file:com.net2plan.gui.GUINet2Plan.java
@Override public void actionPerformed(ActionEvent e) { try {/*from ww w. j a v a 2 s. co m*/ if (!(e.getSource() instanceof JMenuItem)) throw new RuntimeException("Bad"); JMenuItem item = (JMenuItem) e.getSource(); if (item.equals(optionsItem)) { JDialog dialog = new GUIConfiguration(); dialog.setVisible(true); } else if (item.equals(errorConsoleItem)) { ErrorHandling.showConsole(); } else if (item.equals(classPathEditorItem)) { ClassPathEditor.showGUI(); } else if (item.equals(keyCombinationItem)) { showKeyCombinations(); } else if (item.equals(exitItem)) { askForClose(); } else if (item.equals(helpItem)) { loadHelp(); } else if (item.equals(javadocItem)) { loadJavadocLib(); } else if (item.equals(javadocExamplesItem)) { loadExamples(); } else { Object object = itemObject.get(item); WindowUtils.setWindowLeftSide(instance); if (object != null) { if (object instanceof Class) { Object classInstance = ((Class) object).newInstance(); if (classInstance instanceof IGUIModule) { IGUIModule module = (IGUIModule) classInstance; module.start(); object = module; } } if (object instanceof JPanel) { container.removeAll(); container.add((JPanel) object, "grow"); container.revalidate(); container.updateUI(); } } } } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, GUINet2Plan.class); ErrorHandling.showErrorDialog("Unable to execute option"); } }
From source file:Main.java
public Main() { int MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); KeyStroke exitKey = KeyStroke.getKeyStroke(KeyEvent.VK_W, MASK); this.setDefaultCloseOperation(EXIT_ON_CLOSE); JMenu fileMenu = new JMenu("File"); JMenuItem fileExit = new JMenuItem(exitAction); fileMenu.add(fileExit);/*from w w w. j a v a2 s. co m*/ JMenuBar menu = new JMenuBar(); menu.add(fileMenu); JDialog d = new JDialog(this, "Dialog"); JPanel p = new JPanel(); p.getInputMap().put(exitKey, exitName); p.getActionMap().put(exitName, exitAction); p.add(new JButton(exitAction)); d.add(p); d.pack(); d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setJMenuBar(menu); this.pack(); this.setSize(new Dimension(320, 240)); this.setVisible(true); d.setLocation(this.getRootPane().getContentPane().getLocationOnScreen()); d.setVisible(true); }
From source file:org.yccheok.jstock.gui.charting.DynamicChart.java
public void showNewJDialog(java.awt.Frame parent, String title) { TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(this.price); JFreeChart freeChart = ChartFactory.createTimeSeriesChart(title, GUIBundle.getString("DynamicChart_Date"), GUIBundle.getString("DynamicChart_Price"), dataset, true, true, false); freeChart.setAntiAlias(true);/*from w ww .j a v a 2s .c o m*/ XYPlot plot = freeChart.getXYPlot(); NumberAxis rangeAxis1 = (NumberAxis) plot.getRangeAxis(); DecimalFormat format = new DecimalFormat("00.00"); rangeAxis1.setNumberFormatOverride(format); XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("h:mm:ss a"), new DecimalFormat("0.00#"))); org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart); ChartPanel _chartPanel = new ChartPanel(freeChart, true, true, true, true, true); JDialog dialog = new JDialog(parent, title, false); dialog.getContentPane().add(_chartPanel, java.awt.BorderLayout.CENTER); dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); final java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); dialog.setBounds((screenSize.width - 750) >> 1, (screenSize.height - 600) >> 1, 750, 600); dialog.setVisible(true); }
From source file:com.digitalgeneralists.assurance.ui.MainWindow.java
public void displayAboutDialog() { JDialog aboutApplicationDialog = dialogFactory.createAboutDialogInstance(this, ModalityType.APPLICATION_MODAL); aboutApplicationDialog.setVisible(true); }
From source file:com.digitalgeneralists.assurance.ui.components.ScanDefinitionPanel.java
private void displayMappingDefinitionDialog(ScanMappingDefinition selectedItem) { Window parent = SwingUtilities.getWindowAncestor(this.getParent()); JDialog scanMappingDefinitionDialog = this.dialogFactory.createScanMappingDefinitionDialogInstance(parent, ModalityType.APPLICATION_MODAL, this, selectedItem); scanMappingDefinitionDialog.setVisible(true); }
From source file:com.digitalgeneralists.assurance.ui.MainWindow.java
public void displayPreferencesDialog() { JDialog settingsDialog = dialogFactory.createSettingsDialogInstance(this, ModalityType.APPLICATION_MODAL, this.applicationConfiguration); settingsDialog.setVisible(true); }