Examples of JOptionPane


Examples of charvax.swing.JOptionPane

        String selected_option = null;

        String[] message = { "This shows how to create and use",
                "a JOptionPane directly, without using",
                "the convenience methods"};
        JOptionPane pane = new JOptionPane(message);

        // Make the dialog display a JTextField for user input.
        pane.setWantsInput(true);

        // Set the initial input value displayed to the user.
        pane.setInitialSelectionValue("default input value");

        // Provide customized button labels.
        String[] options = { "Option 1", "Option 2", "Option 3", "Option 4"};
        pane.setOptions(options);

        // Make "Option 2" the default button.
        pane.setInitialValue("Option 2");

        JDialog dialog = pane.createDialog(parent_, "Custom JOptionPane");
        dialog.show();
        Object selectedValue = pane.getValue();
        System.err.println("Selected value is " + selectedValue);
        results[ 0] = "The input value is \"" + (String) pane.getInputValue()
                + "\"";

        // If there is NOT an array of option buttons:
        // (In this case, there is).
        if (pane.getOptions() == null) {
            int option = ((Integer) selectedValue).intValue();
            switch (option) {
            case JOptionPane.YES_OPTION:
                selected_option = "YES";
                break;
View Full Code Here

Examples of javax.swing.JOptionPane

    super(name);
  }

  protected boolean downloadFrom(final String url) throws TvBrowserException {
    if(!isStable() && Settings.propPluginBetaWarning.getBoolean()) {
      JOptionPane pane = new JOptionPane();
     
      String ok = mLocalizer.msg("betawarning.oktext","Install beta version");
      String cancel = mLocalizer.msg("betawarning.canceltext","Cancel installation");
     
      pane.setOptions(new String[] {ok,cancel});
      pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
      pane.setOptionType(JOptionPane.YES_NO_OPTION);
      pane.setInitialValue(cancel);
      pane.setMessage(mLocalizer.msg("betawarning.text","<html>The plugin <b>{0}</b> is a beta version.<br>Beta versions are possible unstable and could contain errors.<br><br>Are you sure that you want to install this version?</html>",getName() + " " + getVersion()));
     
      Window w = UiUtilities.getLastModalChildOf(MainFrame.getInstance());
     
      JDialog dialog = pane.createDialog(w, mLocalizer.msg("betawarning.title","Beta version"));
      dialog.setModal(true);
      dialog.setLocationRelativeTo(w);
      dialog.setVisible(true);
     
      if(!ok.equals(pane.getValue())) {
        return false;
      }
    }

    final File toFile=new File(Settings.propPluginsDirectory.getString(),getClassName() + ".jar.inst");
View Full Code Here

Examples of javax.swing.JOptionPane

    gc.anchor = GridBagConstraints.LINE_START;
    gb.setConstraints(label, gc); panel.add(label);
    gb.setConstraints(field, gc); panel.add(field);
    gb.setConstraints(error, gc); panel.add(error);
    gb.setConstraints(strut, gc); panel.add(strut);
    JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE,
        JOptionPane.OK_CANCEL_OPTION);
    pane.setInitialValue(field);
    JDialog dlog = pane.createDialog(frame, Strings.get("circuitNameDialogTitle"));
    dlog.addWindowFocusListener(new WindowFocusListener() {
      public void windowGainedFocus(WindowEvent arg0) {
        field.requestFocus();
      }

      public void windowLostFocus(WindowEvent arg0) { }
    });
   
    while (true) {
      field.selectAll();
      dlog.pack();
      dlog.setVisible(true);
      field.requestFocusInWindow();
      Object action = pane.getValue();
      if (action == null || !(action instanceof Integer)
          || ((Integer) action).intValue() != JOptionPane.OK_OPTION) {
        return null;
      }
View Full Code Here

Examples of javax.swing.JOptionPane

   
    JPanel main = new JPanel(new BorderLayout());
    mFrame.setContentPane(main);

    msg = mLocalizer.msg("error.message", "No browser found.\n\nDo you want to choose a browser now?");
    mOptionPane = new JOptionPane(msg, JOptionPane.ERROR_MESSAGE, JOptionPane.YES_NO_OPTION);
    mOptionPane.addPropertyChangeListener(new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent evt) {
        if (evt.getPropertyName().equals(JOptionPane.VALUE_PROPERTY) &&
            evt.getNewValue() != null &&
            evt.getNewValue() != JOptionPane.UNINITIALIZED_VALUE)
View Full Code Here

Examples of javax.swing.JOptionPane

     * @param parent  component that dialog is modal on
     * @param body    body text of dialog
     * @param title   title of dialog
     */
    public static void modalError(Component parent, String body, String title) {
        JOptionPane errorDialog = new JOptionPane();
        errorDialog.showMessageDialog(parent, body, title, JOptionPane.ERROR_MESSAGE);
    }
View Full Code Here

Examples of javax.swing.JOptionPane

        e.printStackTrace();
        modalError(parent, body, title);
    }
   
    public static void nonModalError(String body, String title, Exception e) {
        JOptionPane errorDialog = new JOptionPane();
        errorDialog.showMessageDialog(null, body, title, JOptionPane.ERROR_MESSAGE);
    }
View Full Code Here

Examples of javax.swing.JOptionPane

    private boolean overwriteDialog(String oldValue, String newValue,
            String fieldName) {
        boolean retval = false;
        Object[] possibilities = { "Yes", "Yes to All", "No", "No to All" };

        final JOptionPane optionPane = new JOptionPane(
                "Do you want to overwrite the value '" + oldValue
                        + "' \nwith the value '" + newValue + "' \nfor the "
                        + fieldName + " field?", JOptionPane.QUESTION_MESSAGE,
                JOptionPane.DEFAULT_OPTION, null, possibilities, "No");

        final JDialog dialog = new JDialog(panel.frame(), "Overwrite Value",
                true);
        dialog.setContentPane(optionPane);
        dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

        optionPane.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
                String prop = e.getPropertyName();

                if (dialog.isVisible() && (e.getSource() == optionPane)
                        && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                    //If you were going to check something
                    //before closing the window, you'd do
                    //it here.
                    dialog.setVisible(false);
                }
            }
        });
        dialog.pack();
        dialog.setVisible(true);

        String userChoice = (String) optionPane.getValue();
        if (userChoice.equals("Yes to All")) {
            overwriteAll.setValue(true);
            retval = true;
        } else if (userChoice.equals("Yes")) {
            retval = true;
View Full Code Here

Examples of javax.swing.JOptionPane

    nameTextField.setText("Test");
    tester.click(areaVisibleCheckBox);
    tester.click(floorVisibleCheckBox);
    tester.click(ceilingVisibleCheckBox);
   
    final JOptionPane attributesOptionPane = (JOptionPane)TestUtilities.findComponent(
        attributesDialog, JOptionPane.class);
    tester.invokeAndWait(new Runnable() {
        public void run() {
          // Select Ok option to hide dialog box in Event Dispatch Thread
          attributesOptionPane.setValue(JOptionPane.OK_OPTION);
        }
      });
    assertFalse("Dialog still showing", attributesDialog.isShowing());
   
    // Assert room was modified accordingly
View Full Code Here

Examples of javax.swing.JOptionPane

  /**
   * Cliks on OK in dialog to close it.
   */
  private void doClickOnOkInDialog(JDialog dialog, JComponentTester tester)
            throws ComponentSearchException {
    final JOptionPane attributesOptionPane = (JOptionPane)TestUtilities.findComponent(
        dialog, JOptionPane.class);
    tester.invokeAndWait(new Runnable() {
        public void run() {
          // Select Ok option to hide dialog box in Event Dispatch Thread
          attributesOptionPane.setValue(JOptionPane.OK_OPTION);
        }
      });
    assertFalse("Dialog still showing", dialog.isShowing());
  }
View Full Code Here

Examples of javax.swing.JOptionPane

  /**
   * Clicks on OK in dialog to close it.
   */
  private void doClickOnOkInDialog(JDialog dialog, JComponentTester tester)
            throws ComponentSearchException {
    final JOptionPane attributesOptionPane = (JOptionPane)TestUtilities.findComponent(
        dialog, JOptionPane.class);
    tester.invokeAndWait(new Runnable() {
        public void run() {
          // Select Ok option to hide dialog box in Event Dispatch Thread
          if (attributesOptionPane.getOptions() != null) {
            attributesOptionPane.setValue(attributesOptionPane.getOptions() [0]);
          } else {
            attributesOptionPane.setValue(JOptionPane.OK_OPTION);
          }
        }
      });
    assertFalse("Dialog still showing", dialog.isShowing());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.