Example usage for javax.swing JOptionPane PLAIN_MESSAGE

List of usage examples for javax.swing JOptionPane PLAIN_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane PLAIN_MESSAGE.

Prototype

int PLAIN_MESSAGE

To view the source code for javax.swing JOptionPane PLAIN_MESSAGE.

Click Source Link

Document

No icon is used.

Usage

From source file:scrabble.frmStartup.java

private void btnAgregarJugadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarJugadorActionPerformed

    String s = (String) JOptionPane.showInputDialog(this.getContentPane(), "Nombre: ", "Agregar Jugador",
            JOptionPane.PLAIN_MESSAGE, null, null, "");

    //If a string was returned, say so.
    if ((s != null) && (s.length() > 0)) {
        jugadores.addElement(s);//from   w ww. j  a va2 s .co  m
        if (jugadores.size() > 0)
            btnQuitarJugador.setEnabled(true);
        return;
    }

}

From source file:se.trixon.jota.client.ui.editor.JobsPanel.java

private void edit(Job job) {
    String title;//from w ww .  ja  va  2 s  .  c o m
    boolean add = job == null;
    String type = Dict.JOB.toString().toLowerCase();
    if (job == null) {
        job = new Job();
        title = String.format("%s %s", Dict.ADD.toString(), type);
    } else {
        title = String.format("%s %s", Dict.EDIT.toString(), type);
    }

    JobPanel jobPanel = new JobPanel();
    jobPanel.setJob(job);
    SwingHelper.makeWindowResizable(jobPanel);
    int retval = JOptionPane.showOptionDialog(getRoot(), jobPanel, title, JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE, null, null, null);

    if (retval == JOptionPane.OK_OPTION) {
        Job modifiedJob = jobPanel.getJob();
        if (modifiedJob.isValid() && !jobExists(modifiedJob)) {
            if (add) {
                getModel().addElement(modifiedJob);
            } else {
                getModel().set(getModel().indexOf(getSelectedJob()), modifiedJob);
            }
            sortModel();
            list.setSelectedValue(modifiedJob, true);
        } else {
            showInvalidJobDialog();
            edit(modifiedJob);
        }
    }
}

From source file:se.trixon.jota.client.ui.editor.module.DualListPanel.java

private String requestArg(OptionHandler optionHandler) {
    String input = JOptionPane.showInputDialog(this, optionHandler.getLongArg(), optionHandler.getTitle(),
            JOptionPane.PLAIN_MESSAGE);

    if (input != null) {
        input = input.trim();//from w w w . j ava  2s.c  o  m
        boolean invalidInput = StringUtils.isBlank(input);

        String[] intKeys = { "num", "port", "rate", "seconds", "size" };
        String argType = StringUtils.split(optionHandler.getLongArg(), "=", 2)[1].toLowerCase();

        boolean shouldBeInt = ArrayUtils.contains(intKeys, argType);

        if (shouldBeInt) {
            try {
                Integer.parseInt(input);
            } catch (NullPointerException | NumberFormatException e) {
                invalidInput = true;
            }
        } else if (optionHandler instanceof RsyncOption && optionHandler == RsyncOption.CHOWN) {
            invalidInput = input.startsWith(":") || input.endsWith(":")
                    || StringUtils.countMatches(input, ":") != 1;
        }

        if (invalidInput) {
            Message.error(this, "Invalid input", "try again");
            input = requestArg(optionHandler);
        } else {
            return input;
        }
    }

    return input;
}

From source file:se.trixon.jota.client.ui.editor.module.job.CronEditorPanel.java

private void edit(String cronString) {
    String title;/*from w w w . jav  a  2 s . c o m*/
    boolean add = cronString == null;
    if (cronString == null) {
        title = Dict.ADD.toString();
    } else {
        title = Dict.EDIT.toString();
    }

    CronPanel cronPanel = new CronPanel();
    cronPanel.setCronString(cronString);
    SwingHelper.makeWindowResizable(cronPanel);

    int retval = JOptionPane.showOptionDialog(getRoot(), cronPanel, title, JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE, null, null, null);

    if (retval == JOptionPane.OK_OPTION) {
        String modifiedCronString = cronPanel.getCronString();
        if (cronPanel.isCronValid()) {
            if (add) {
                getModel().addElement(modifiedCronString);
            } else {
                getModel().set(getModel().indexOf(getSelectedCronString()), modifiedCronString);
            }
            sortModel();
            list.setSelectedValue(modifiedCronString, true);
        } else {
            Message.error(this, "Invalid cron string", modifiedCronString);
            edit(modifiedCronString);
        }
    }
}

From source file:se.trixon.jota.client.ui.editor.TasksPanel.java

private void edit(Task task) {
    String title;/*from   w  w  w.  j  a  va  2 s .c om*/
    boolean add = task == null;
    String type = Dict.TASK.toString().toLowerCase();
    if (task == null) {
        task = new Task();
        title = String.format("%s %s", Dict.ADD.toString(), type);
    } else {
        title = String.format("%s %s", Dict.EDIT.toString(), type);
    }

    TaskPanel taskPanel = new TaskPanel();
    taskPanel.setTask(task);
    SwingHelper.makeWindowResizable(taskPanel);

    int retval = JOptionPane.showOptionDialog(getRoot(), taskPanel, title, JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE, null, null, null);

    if (retval == JOptionPane.OK_OPTION) {
        Task modifiedTask = taskPanel.getTask();
        if (modifiedTask.isValid()) {
            if (add) {
                getModel().addElement(modifiedTask);
            } else {
                getModel().set(getModel().indexOf(getSelectedTask()), modifiedTask);
            }
            sortModel();
            list.setSelectedValue(modifiedTask, true);
            notifyTaskListenersChanged();
        } else {
            showInvalidTaskDialog();
            edit(modifiedTask);
        }
    }
}

From source file:se.trixon.jota.client.ui.MainFrame.java

public boolean requestStartJob(Job job) {
    try {/*w w  w .jav a  2s. c o  m*/
        JobValidator validator = mManager.getServerCommander().validate(job);
        if (validator.isValid()) {
            Object[] options = { Dict.RUN.toString(), Dict.DRY_RUN.toString(), Dict.CANCEL.toString() };
            HtmlPanel htmlPanel = new HtmlPanel(job.getSummaryAsHtml());
            SwingHelper.makeWindowResizable(htmlPanel);

            int result = JOptionPane.showOptionDialog(this, htmlPanel, Dict.RUN.toString(),
                    JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[1]);

            if (result > -1 && result < 2) {
                boolean dryRun = result == 1;
                mManager.getServerCommander().startJob(job, dryRun);
            }
        } else {
            Message.html(this, Dict.ERROR_VALIDATION.toString(), validator.getSummaryAsHtml());
        }
    } catch (RemoteException ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    return false;
}

From source file:se.trixon.jota.client.ui.MainFrame.java

private void requestConnect() throws NotBoundException {
    String[] hosts = mOptions.getHosts().split(";");
    Arrays.sort(hosts);/*from w  w  w.  j a v a2  s.c o m*/
    DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel(hosts);
    JComboBox hostComboBox = new JComboBox(comboBoxModel);
    hostComboBox.setEditable(true);

    hostComboBox.setSelectedItem(mClient.getHost());
    JTextField portTextField = new JTextField(String.valueOf(mClient.getPortHost()));
    final JComponent[] inputs = new JComponent[] { new JLabel(Dict.HOST.toString()), hostComboBox,
            new JLabel(Dict.PORT.toString()), portTextField, };

    Object[] options = { Dict.CONNECT.toString(), Dict.CANCEL.toString() };
    int retval = JOptionPane.showOptionDialog(this, inputs, Dict.CONNECT_TO_HOST.toString(),
            JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);

    if (retval == 0) {
        String currentHost = mClient.getHost();
        int currentPort = mClient.getPortHost();
        String host = (String) hostComboBox.getSelectedItem();
        String portString = portTextField.getText();

        try {
            int port = Integer.valueOf(portString);
            mManager.disconnect();
            mManager.connect(host, port);

            if (comboBoxModel.getIndexOf(host) == -1) {
                comboBoxModel.addElement(host);
            }
            mOptions.setHosts(SwingHelper.comboBoxModelToString(comboBoxModel));
        } catch (NumberFormatException e) {
            Message.error(this, Dict.ERROR.toString(), String.format(Dict.INVALID_PORT.toString(), portString));
        } catch (NotBoundException | MalformedURLException | RemoteException | SocketException ex) {
            Message.error(this, Dict.ERROR.toString(), ex.getLocalizedMessage());
            mClient.setHost(currentHost);
            mClient.setPortHost(currentPort);
        }
    }
}

From source file:se.trixon.jota.client.ui.MainFrame.java

void showEditor(long jobId, boolean openJob) {
    EditorPanel editorPanel = new EditorPanel(jobId, openJob);
    SwingHelper.makeWindowResizable(editorPanel);

    int retval = JOptionPane.showOptionDialog(this, editorPanel, mBundle.getString("jobEditor"),
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);

    if (retval == JOptionPane.OK_OPTION) {
        editorPanel.save();/* w  w w. java2 s.c  om*/
        try {
            mManager.getServerCommander().saveJota();
        } catch (RemoteException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:se.trixon.jota.client.ui.MainFrame.java

private void showOptions() {
    OptionsPanel optionsPanel = new OptionsPanel();
    SwingHelper.makeWindowResizable(optionsPanel);

    int retval = JOptionPane.showOptionDialog(this, optionsPanel, Dict.OPTIONS.toString(),
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);

    if (retval == JOptionPane.OK_OPTION) {
        optionsPanel.save();//from  w  ww  . j a va  2 s .  co m
    }
}

From source file:se.trixon.mapollage.ui.MainFrame.java

private String requestProfileName(String title, String value) {
    return (String) JOptionPane.showInputDialog(this, null, title, JOptionPane.PLAIN_MESSAGE, null, null,
            value);/* ww w.  j  a v a  2s  . c o m*/
}