List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:edu.umass.cs.gnsserver.installer.EC2Runner.java
private static boolean showDialog(String message, final long timeout) { try {/* w w w . j a v a2 s . c o m*/ int dialog = JOptionPane.YES_NO_OPTION; JOptionPane optionPane = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); final JDialog dlg = optionPane.createDialog("Error"); new Thread(new Runnable() { @Override public void run() { { ThreadUtils.sleep(timeout); dlg.dispose(); } } }).start(); dlg.setVisible(true); int value = ((Integer) optionPane.getValue()).intValue(); if (value == JOptionPane.YES_OPTION) { return true; } else { return false; } } catch (RuntimeException e) { return true; } }
From source file:biomine.bmvis2.pipeline.sources.QueryGraphSource.java
public static QueryGraphSource createFromDialog(Collection<VisualNode> start, String database) { final CrawlSuggestionList sel = new CrawlSuggestionList(); final JDialog dial = new JDialog(); if (database != null) sel.setDatabase(database);//from w ww . jav a 2s. c om for (VisualNode vn : start) { if (vn.getBMNode() != null) sel.addNode(vn); } dial.setModalityType(ModalityType.APPLICATION_MODAL); final CrawlQuery q = new CrawlQuery(); // Helper class to pass back data from anonymous inner classes to this method class Z { boolean okPressed = false; } final Z z = new Z(); JButton okButton = new JButton(new AbstractAction("OK") { public void actionPerformed(ActionEvent arg0) { dial.setVisible(false); q.addAll(sel.getQueryTerms()); z.okPressed = true; } }); JPanel pane = new JPanel(); pane.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weightx = 1; c.weighty = 1; c.fill = c.BOTH; c.gridwidth = 2; c.gridx = 0; c.gridy = 0; pane.add(sel, c); c.weighty = 0; c.gridy++; c.fill = c.HORIZONTAL; c.gridwidth = 1; pane.add(okButton, c); dial.setContentPane(pane); dial.setSize(600, 500); dial.setVisible(true);//this will hopefully block if (z.okPressed) { if (q.size() == 0) { JOptionPane.showMessageDialog(dial, "At least 1 edge must be selected: no queries added"); return null; } return new QueryGraphSource(q, sel.getDatabase()); } return null; }
From source file:Main.java
private void ShowDialog() { JLabel label = new JLabel("Move mouse here for hand cursor"); label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JOptionPane pane = new JOptionPane(label); pane.setOptions(new Object[] { "OK" }); JDialog dialog = pane.createDialog(this, "Test Dialog"); dialog.setVisible(true); }
From source file:Main.java
public void launchDialog() { JButton findButton = new JButton("Find"); findButton.addActionListener(e -> { int start = text.getText().indexOf("is"); int end = start + "is".length(); if (start != -1) { text.requestFocus();/*from w w w . j ava 2 s. c om*/ text.select(start, end); } }); JButton cancelButton = new JButton("Cancel"); JOptionPane optionPane = new JOptionPane("Do you understand?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, new Object[] { findButton, cancelButton }); JDialog dialog = new JDialog(frame, "Click a button", false); cancelButton.addActionListener(e -> dialog.setVisible(false)); dialog.setContentPane(optionPane); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.setLocation(100, 100); dialog.pack(); dialog.setVisible(true); }
From source file:Main.java
Main() { Object[][] data = { { "A", "B", "Snowboarding", new Integer(5) }, { "C", "D", "Pool", new Integer(10) } }; Object[] columnNames = { "firstname", "lastname", "age" }; final JTable table = new JTable(data, columnNames) { @Override/*from www . j av a2s . com*/ public Dimension getPreferredScrollableViewportSize() { Dimension d = getPreferredSize(); int n = getRowHeight(); return new Dimension(d.width, (n * ROWS)); } }; JPanel jPanel = new JPanel(); jPanel.setLayout(new GridLayout()); JScrollPane sp = new JScrollPane(table); jPanel.add(sp); JDialog jdialog = new JDialog(); jdialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); jdialog.setContentPane(jPanel); jdialog.pack(); jdialog.setVisible(true); }
From source file:ca.nengo.ui.util.DialogPlotter.java
@Override protected void showChart(JFreeChart chart, String title) { JPanel panel = new ChartPanel(chart); JDialog dialog = new JDialog(parent, title); dialog.getContentPane().add(panel, BorderLayout.CENTER); dialog.pack();//from ww w .jav a 2s. com dialog.setVisible(true); }
From source file:Modelos.Grafica.java
public ChartPanel mostrarGrafica(Window owner) { ChartPanel panel = new ChartPanel(chart); JDialog ventana; ventana = new JDialog(owner, "Grafica"); ventana.getContentPane().add(panel); ventana.pack();//from w w w . j ava 2 s . com ventana.setVisible(true); //ventana.dispose(); ventana.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); return panel; }
From source file:OptPaneComparison.java
public OptPaneComparison(final String message) { setDefaultCloseOperation(EXIT_ON_CLOSE); final int msgType = JOptionPane.QUESTION_MESSAGE; final int optType = JOptionPane.OK_CANCEL_OPTION; final String title = message; setSize(350, 200);/*from w ww . j a va 2s .c o m*/ // Create a desktop for internal frames final JDesktopPane desk = new JDesktopPane(); setContentPane(desk); // Add a simple menu bar JMenuBar mb = new JMenuBar(); setJMenuBar(mb); JMenu menu = new JMenu("Dialog"); JMenu imenu = new JMenu("Internal"); mb.add(menu); mb.add(imenu); final JMenuItem construct = new JMenuItem("Constructor"); final JMenuItem stat = new JMenuItem("Static Method"); final JMenuItem iconstruct = new JMenuItem("Constructor"); final JMenuItem istat = new JMenuItem("Static Method"); menu.add(construct); menu.add(stat); imenu.add(iconstruct); imenu.add(istat); // Create our JOptionPane. We're asking for input, so we call // setWantsInput. // Note that we cannot specify this via constructor parameters. optPane = new JOptionPane(message, msgType, optType); optPane.setWantsInput(true); // Add a listener for each menu item that will display the appropriate // dialog/internal frame construct.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { // Create and display the dialog JDialog d = optPane.createDialog(desk, title); d.setVisible(true); respond(getOptionPaneValue()); } }); stat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { String s = JOptionPane.showInputDialog(desk, message, title, msgType); respond(s); } }); iconstruct.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { // Create and display the dialog JInternalFrame f = optPane.createInternalFrame(desk, title); f.setVisible(true); // Listen for the frame to close before getting the value from // it. f.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent ev) { if ((ev.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY)) && (ev.getNewValue() == Boolean.TRUE)) { respond(getOptionPaneValue()); } } }); } }); istat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { String s = JOptionPane.showInternalInputDialog(desk, message, title, msgType); respond(s); } }); }
From source file:Main.java
/** * Creates an animation to fade the dialog opacity from 0 to 1, wait at 1 * and then fade to 0 and dispose.//from w w w . j a v a2s . c o m * * @param dialog the dialog to display * @param delay the delay in ms before starting and between each change * @param incrementSize the increment size * @param displayTime the time in ms the dialog is fully visible */ public static void fadeInAndOut(final JDialog dialog, final int delay, final float incrementSize, final int displayTime) { final Timer timer = new Timer(delay, null); timer.setRepeats(true); timer.addActionListener(new ActionListener() { private float opacity = 0; private boolean displayed = false; @Override public void actionPerformed(ActionEvent e) { if (!displayed) { opacity += incrementSize; dialog.setOpacity(Math.min(opacity, 1)); // requires java 1.7 if (opacity >= 1) { timer.setDelay(displayTime); displayed = true; } } else { timer.setDelay(delay); opacity -= incrementSize; dialog.setOpacity(Math.max(opacity, 0)); // requires java 1.7 if (opacity < 0) { timer.stop(); dialog.dispose(); } } } }); dialog.setOpacity(0); // requires java 1.7 timer.start(); dialog.setVisible(true); }
From source file:de.atomfrede.tools.evalutation.util.DialogUtil.java
public void showStandardDialog(final JDialog dialogToShow) { SwingUtilities.invokeLater(new Runnable() { @Override/*from www .j ava2 s . c o m*/ public void run() { dialogToShow.setVisible(true); } }); }