Example usage for javax.swing JDialog setDefaultCloseOperation

List of usage examples for javax.swing JDialog setDefaultCloseOperation

Introduction

In this page you can find the example usage for javax.swing JDialog setDefaultCloseOperation.

Prototype

@BeanProperty(preferred = true, enumerationValues = { "WindowConstants.DO_NOTHING_ON_CLOSE",
        "WindowConstants.HIDE_ON_CLOSE",
        "WindowConstants.DISPOSE_ON_CLOSE" }, description = "The dialog's default close operation.")
public void setDefaultCloseOperation(int operation) 

Source Link

Document

Sets the operation that will happen by default when the user initiates a "close" on this dialog.

Usage

From source file:org.pgptool.gui.ui.importkey.KeyImporterView.java

@Override
protected JDialog initDialog(Window owner, Object constraints) {
    JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
    ret.setLayout(new BorderLayout());
    ret.setResizable(true);/*from   ww w .  ja  v a  2s .  c om*/
    ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    ret.setTitle(Messages.get("action.importKey"));
    ret.add(pnl, BorderLayout.CENTER);
    ret.setMinimumSize(new Dimension(spacing(60), spacing(30)));

    initWindowGeometryPersister(ret, "keyImprt");

    return ret;
}

From source file:org.uncommons.watchmaker.swing.evolutionmonitor.EvolutionMonitor.java

/**
 * Displays the evolution monitor component in a new {@link JDialog}.  There is no
 * need to make sure this method is invoked from the Event Dispatch Thread, the
 * method itself ensures that the window is created and displayed from the EDT.
 * @param owner The owning frame for the new dialog.
 * @param title The title for the new dialog.
 * @param modal Whether the //from www  .j a  v  a  2  s  .c  o m
 */
public void showInDialog(final JFrame owner, final String title, final boolean modal) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JDialog dialog = new JDialog(owner, title, modal);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            showWindow(dialog);
        }
    });
}

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 ww.  j  a va 2s .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:de.tudarmstadt.ukp.clarin.webanno.webapp.standalone.StandaloneShutdownDialog.java

private void displayShutdownDialog() {
    String serverId = ServerDetector.getServerId();
    log.info("Running in: " + (serverId != null ? serverId : "unknown server"));
    log.info("Console: " + ((System.console() != null) ? "available" : "not available"));
    log.info("Headless: " + (GraphicsEnvironment.isHeadless() ? "yes" : "no"));

    // Show this only when run from the standalone JAR via a double-click
    if (System.console() == null && !GraphicsEnvironment.isHeadless() && ServerDetector.isWinstone()) {
        log.info("If you are running WebAnno in a server environment, please use '-Djava.awt.headless=true'");

        EventQueue.invokeLater(new Runnable() {
            @Override/*from   w  w w  . jav a2s  . c o  m*/
            public void run() {
                final JOptionPane optionPane = new JOptionPane(new JLabel(
                        "<HTML>WebAnno is running now and can be accessed via <a href=\"http://localhost:8080\">http://localhost:8080</a>.<br>"
                                + "WebAnno works best with the browsers Google Chrome or Safari.<br>"
                                + "Use this dialog to shut WebAnno down.</HTML>"),
                        JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_OPTION, null,
                        new String[] { "Shutdown" });

                final JDialog dialog = new JDialog((JFrame) null, "WebAnno", true);
                dialog.setContentPane(optionPane);
                dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
                dialog.addWindowListener(new WindowAdapter() {
                    @Override
                    public void windowClosing(WindowEvent we) {
                        // Avoid closing window by other means than button
                    }
                });
                optionPane.addPropertyChangeListener(new PropertyChangeListener() {
                    @Override
                    public void propertyChange(PropertyChangeEvent aEvt) {
                        if (dialog.isVisible() && (aEvt.getSource() == optionPane)
                                && (aEvt.getPropertyName().equals(JOptionPane.VALUE_PROPERTY))) {
                            System.exit(0);
                        }
                    }
                });
                dialog.pack();
                dialog.setVisible(true);
            }
        });
    } else {
        log.info("Running in server environment or from command line: disabling interactive shutdown dialog.");
    }
}

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);/* w  w w  .ja  v a2s  . 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: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 .  java 2  s  .c o  m
    ventana.setVisible(true);
    //ventana.dispose();
    ventana.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    return panel;
}

From source file:org.pgptool.gui.ui.keyslist.KeysListView.java

@Override
protected JDialog initDialog(Window owner, Object constraints) {
    JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
    ret.setMinimumSize(new Dimension(spacing(50), spacing(25)));
    ret.setLayout(new BorderLayout());
    ret.setResizable(true);/* w  w  w  .  ja  va  2 s  . c om*/
    ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    ret.setTitle(Messages.get("term.keysList"));
    ret.add(panelRoot, BorderLayout.CENTER);
    ret.setJMenuBar(menuBar);
    initWindowGeometryPersister(ret, "keysList");
    return ret;
}

From source file:kenh.xscript.elements.Debug.java

/**
 * a dialog use to debug./* ww w  . j  a v  a  2  s . com*/
 */
public void process() {

    JDialog dialog = new JDialog((Frame) null, true);
    dialog.setTitle("Debugger");
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setSize(750, 200);
    initial(dialog.getContentPane());
    dialog.setVisible(true);

    this.result = null;

}

From source file:net.automatalib.visualization.jung.JungGraphVisualizationProvider.java

@Override
public <N, E> void visualize(Graph<N, E> graph, GraphDOTHelper<N, ? super E> helper, boolean modal,
        Map<String, String> options) {

    DirectedGraph<NodeVisualization, EdgeVisualization> visGraph = createVisualizationGraph(graph, helper);

    Layout<NodeVisualization, EdgeVisualization> layout = new KKLayout<>(visGraph);

    VisualizationViewer<NodeVisualization, EdgeVisualization> vv = new VisualizationViewer<>(layout);
    setupRenderContext(vv.getRenderContext());
    vv.setGraphMouse(mouse);//from   www. ja  va2 s .  c  o  m

    final JDialog frame = new JDialog((Dialog) null, "Visualization", modal);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.getContentPane().add(vv);
    frame.pack();
    frame.setVisible(true);
}

From source file:com.softeffect.primemovers.ui.ClientApplication.java

/**
 * @param parentFrame// w ww. j a va2  s.co m
 *            parent frame
 * @return a dialog window to logon the application; the method can return
 *         null if viewLoginInMenuBar returns false
 */
public JDialog viewLoginDialog(JFrame parentFrame) {
    JDialog d = new LoginDialog(frame, true, this, "Authentication", "Login", 'L', "Exit", 'E', "Store Account",
            applicationInfo.getName());
    d.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    return d;
}