Search in sources :

Example 6 with JDialog

use of javax.swing.JDialog in project smile by haifengl.

the class FontChooser method showDialog.

/**
     *  Show font selection dialog.
     *  @param parent Dialog's Parent component.
     *  @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION
     *
     *  @see #OK_OPTION 
     *  @see #CANCEL_OPTION
     *  @see #ERROR_OPTION
     **/
public int showDialog(Component parent) {
    dialogResultValue = ERROR_OPTION;
    JDialog dialog = createDialog(parent);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            dialogResultValue = CANCEL_OPTION;
        }
    });
    dialog.setVisible(true);
    dialog.dispose();
    dialog = null;
    return dialogResultValue;
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) JDialog(javax.swing.JDialog)

Example 7 with JDialog

use of javax.swing.JDialog in project binnavi by google.

the class CNodeFunctions method editNodeComments.

/**
   * Shows a dialog to edit the comments of a node.
   * 
   * @param node The node whose comments are edited.
   * @param initialTab The initially visible tab.
   */
public static void editNodeComments(final CGraphModel model, final INaviViewNode node, final InitialTab initialTab) {
    Preconditions.checkNotNull(node, "IE02131: Node argument can not be null");
    final JDialog dialog = getCommentDialog(model, node, initialTab);
    GuiHelper.centerChildToParent(model.getParent(), dialog, true);
    dialog.setVisible(true);
}
Also used : JDialog(javax.swing.JDialog)

Example 8 with JDialog

use of javax.swing.JDialog in project binnavi by google.

the class CColorChooser method showDialog.

public static Color showDialog(final Component parent, final String title, final Color initialColor, final Color[] recentColors) throws HeadlessException {
    final CColorChooser pane = new CColorChooser(initialColor, recentColors);
    final SelectedColorActionListener ok = pane.new SelectedColorActionListener();
    final JDialog dlg = createDialog(parent, title, true, pane, ok, null);
    dlg.setVisible(true);
    dlg.dispose();
    return ok.getColor();
}
Also used : JDialog(javax.swing.JDialog)

Example 9 with JDialog

use of javax.swing.JDialog in project processing by processing.

the class Messages method showYesNoCancelQuestion.

// ...................................................................
// incomplete
public static int showYesNoCancelQuestion(Editor editor, String title, String primary, String secondary) {
    if (!Platform.isMacOS()) {
        int result = JOptionPane.showConfirmDialog(null, primary + "\n" + secondary, title, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
        return result;
    //    if (result == JOptionPane.YES_OPTION) {
    //
    //    } else if (result == JOptionPane.NO_OPTION) {
    //      return true;  // ok to continue
    //
    //    } else if (result == JOptionPane.CANCEL_OPTION) {
    //      return false;
    //
    //    } else {
    //      throw new IllegalStateException();
    //    }
    } else {
        // Pane formatting adapted from the Quaqua guide
        // http://www.randelshofer.ch/quaqua/guide/joptionpane.html
        JOptionPane pane = new JOptionPane("<html> " + "<head> <style type=\"text/css\">" + "b { font: 13pt \"Lucida Grande\" }" + "p { font: 11pt \"Lucida Grande\"; margin-top: 8px; width: 300px }" + "</style> </head>" + "<b>" + Language.text("save.title") + "</b>" + "<p>" + Language.text("save.hint") + "</p>", JOptionPane.QUESTION_MESSAGE);
        String[] options = new String[] { Language.text("save.btn.save"), Language.text("prompt.cancel"), Language.text("save.btn.dont_save") };
        pane.setOptions(options);
        // highlight the safest option ala apple hig
        pane.setInitialValue(options[0]);
        // on macosx, setting the destructive property places this option
        // away from the others at the lefthand side
        pane.putClientProperty("Quaqua.OptionPane.destructiveOption", Integer.valueOf(2));
        JDialog dialog = pane.createDialog(editor, null);
        dialog.setVisible(true);
        Object result = pane.getValue();
        if (result == options[0]) {
            return JOptionPane.YES_OPTION;
        } else if (result == options[1]) {
            return JOptionPane.CANCEL_OPTION;
        } else if (result == options[2]) {
            return JOptionPane.NO_OPTION;
        } else {
            return JOptionPane.CLOSED_OPTION;
        }
    }
}
Also used : JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Example 10 with JDialog

use of javax.swing.JDialog in project processing by processing.

the class Messages method showWarningTiered.

/**
   * Non-fatal error message with optional stack trace side dish.
   */
public static void showWarningTiered(String title, String primary, String secondary, Throwable e) {
    if (title == null)
        title = "Warning";
    final String message = primary + "\n" + secondary;
    if (Base.isCommandLine()) {
        System.out.println(title + ": " + message);
    } else {
        //                                    title, JOptionPane.WARNING_MESSAGE);
        if (!Platform.isMacOS()) {
            JOptionPane.showMessageDialog(new JFrame(), "<html><body>" + "<b>" + primary + "</b>" + "<br>" + secondary, title, JOptionPane.WARNING_MESSAGE);
        } else {
            // Pane formatting adapted from the Quaqua guide
            // http://www.randelshofer.ch/quaqua/guide/joptionpane.html
            JOptionPane pane = new JOptionPane("<html> " + "<head> <style type=\"text/css\">" + "b { font: 13pt \"Lucida Grande\" }" + "p { font: 11pt \"Lucida Grande\"; margin-top: 8px; width: 300px }" + "</style> </head>" + "<b>" + primary + "</b>" + "<p>" + secondary + "</p>", JOptionPane.WARNING_MESSAGE);
            //        String[] options = new String[] {
            //            "Yes", "No"
            //        };
            //        pane.setOptions(options);
            // highlight the safest option ala apple hig
            //        pane.setInitialValue(options[0]);
            JDialog dialog = pane.createDialog(new JFrame(), null);
            dialog.setVisible(true);
        //        Object result = pane.getValue();
        //        if (result == options[0]) {
        //          return JOptionPane.YES_OPTION;
        //        } else if (result == options[1]) {
        //          return JOptionPane.NO_OPTION;
        //        } else {
        //          return JOptionPane.CLOSED_OPTION;
        //        }
        }
    }
    if (e != null)
        e.printStackTrace();
}
Also used : JFrame(javax.swing.JFrame) JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Aggregations

JDialog (javax.swing.JDialog)181 JButton (javax.swing.JButton)70 JPanel (javax.swing.JPanel)61 ActionEvent (java.awt.event.ActionEvent)51 ActionListener (java.awt.event.ActionListener)39 JLabel (javax.swing.JLabel)39 JOptionPane (javax.swing.JOptionPane)34 BorderLayout (java.awt.BorderLayout)30 Dimension (java.awt.Dimension)27 JScrollPane (javax.swing.JScrollPane)27 JFrame (javax.swing.JFrame)23 BoxLayout (javax.swing.BoxLayout)21 FlowLayout (java.awt.FlowLayout)19 JCheckBox (javax.swing.JCheckBox)15 AbstractAction (javax.swing.AbstractAction)14 WindowEvent (java.awt.event.WindowEvent)13 JComponent (javax.swing.JComponent)12 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 WindowAdapter (java.awt.event.WindowAdapter)11 IOException (java.io.IOException)10