Example usage for javax.swing JOptionPane showInputDialog

List of usage examples for javax.swing JOptionPane showInputDialog

Introduction

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

Prototype

@SuppressWarnings("deprecation")
public static Object showInputDialog(Component parentComponent, Object message, String title, int messageType,
        Icon icon, Object[] selectionValues, Object initialSelectionValue) throws HeadlessException 

Source Link

Document

Prompts the user for input in a blocking dialog where the initial selection, possible selections, and all other options can be specified.

Usage

From source file:fi.hoski.remote.ui.Admin.java

private JMenuItem menuItemRestoreEntity() {
    final String title = TextUtil.getText("RESTORE ENTITY");
    JMenuItem backupYearItem = new JMenuItem(title);
    ActionListener backupYearAction = new ActionListener() {

        @Override//  www .  j  a va2 s . co  m
        public void actionPerformed(ActionEvent e) {
            Object kind = JOptionPane.showInputDialog(frame, title, "", JOptionPane.OK_CANCEL_OPTION, null,
                    serverProperties.getTables(), null);
            if (kind != null) {
                File file = openFile(BACKUPDIR, ".ser", "Backup");
                if (file != null) {
                    int count;
                    try (FileInputStream fos = new FileInputStream(file)) {
                        BufferedInputStream bis = new BufferedInputStream(fos);
                        ObjectInputStream ois = new ObjectInputStream(bis);
                        List<String> list = new ArrayList<String>();
                        list.add(kind.toString());
                        count = dss.restore(list, ois);
                        JOptionPane.showMessageDialog(frame, TextUtil.getText("RESTORED") + " " + count);
                    } catch (IOException ex) {
                        ex.printStackTrace();
                        JOptionPane.showMessageDialog(frame, ex.getMessage());
                    }
                }
            }
        }
    };
    backupYearAction = createActionListener(frame, backupYearAction);
    backupYearItem.addActionListener(backupYearAction);
    return backupYearItem;
}

From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("Rename ...")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog",
                JOptionPane.PLAIN_MESSAGE, null, null,
                ndata.name().substring(0, ndata.name().lastIndexOf("[") - 1));

        if (inputValue != null) {
            String newQueryName = (String) inputValue;
            String requestXml = ndata.writeRenameQueryXML(newQueryName);
            lastRequestMessage = requestXml;

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }//from w w w  .  j a  v  a2  s.co  m
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }
            lastResponseMessage = response;

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        ndata.name(newQueryName + " [" + ndata.userId() + "]");
                        node.setUserObject(ndata);
                        //DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();

                        jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Delete")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?",
                "Delete Query Dialog", JOptionPane.YES_NO_OPTION);
        if (selectedValue.equals(JOptionPane.YES_OPTION)) {
            System.out.println("delete " + ndata.name());
            String requestXml = ndata.writeDeleteQueryXML();
            lastRequestMessage = requestXml;
            //System.out.println(requestXml);

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }
            lastResponseMessage = response;

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        treeModel.removeNodeFromParent(node);

                        //jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) {
        String status = loadPreviousQueries(false);
        if (status.equalsIgnoreCase("")) {
            reset(200, false);
        } else if (status.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
    }
}

From source file:edu.harvard.i2b2.previousquery.ui.QueryPreviousRunsPanel.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("Rename ...")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog",
                JOptionPane.PLAIN_MESSAGE, null, null,
                ndata.name().substring(0, ndata.name().lastIndexOf("[") - 1));

        if (inputValue != null) {
            String newQueryName = (String) inputValue;
            String requestXml = ndata.writeRenameQueryXML(newQueryName);

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                // TO DO
                // response =
                // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
            } else {
                response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            }//from   www . jav  a  2  s .  com

            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        ndata.name(newQueryName + " [" + ndata.userId() + "]");
                        node.setUserObject(ndata);
                        // DefaultMutableTreeNode parent =
                        // (DefaultMutableTreeNode) node.getParent();

                        jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Delete")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?",
                "Delete Query Dialog", JOptionPane.YES_NO_OPTION);
        if (selectedValue.equals(JOptionPane.YES_OPTION)) {
            System.out.println("delete " + ndata.name());
            String requestXml = ndata.writeDeleteQueryXML();
            // System.out.println(requestXml);

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                // TO DO
                // response =
                // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
            } else {
                response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            }

            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        treeModel.removeNodeFromParent(node);

                        // jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) {
        String status = loadPreviousQueries(false);
        if (status.equalsIgnoreCase("")) {
            reset(200, false);
        } else if (status.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
    }
}

From source file:com.freedomotic.jfrontend.MainWindow.java

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

    Object[] possibilities = { "list", "plain", "image", "photo" };
    String input = (String) JOptionPane.showInputDialog(this, i18n.msg("select_renderer"),
            i18n.msg("select_renderer_title"), JOptionPane.PLAIN_MESSAGE, null, possibilities,
            drawer.getCurrEnv().getPojo().getRenderer());

    //If a string was returned
    if ((input != null) && (!input.isEmpty())) {
        changeRenderer(input);/*from  w w w . ja  v  a2s.c  o  m*/
    }
}

From source file:com.mirth.connect.connectors.jms.JmsConnectorPanel.java

private void saveTemplateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveTemplateButtonActionPerformed
    String templateName = null;//from  w  w w . j  av  a 2 s .  c  om
    Object defaultValue = (templateList.getSelectedValue() == null
            || listModel.isPredefinedTemplate(templateList.getSelectedValue().toString())) ? ""
                    : templateList.getSelectedValue();

    do {
        Object response = JOptionPane.showInputDialog(parent, "Enter a name for the connection template:",
                "Save", JOptionPane.QUESTION_MESSAGE, null, null, defaultValue);

        if (response == null) {
            return;
        }

        templateName = StringUtils.trim(response.toString());

        if (templateName.isEmpty()) {
            return;
        }

        if (listModel.isPredefinedTemplate(templateName)) {
            parent.alertWarning(parent, "\"" + templateName
                    + "\" is a reserved template and cannot be overwritten. Please enter a different template name.");
            defaultValue = "";
        }
    } while (listModel.isPredefinedTemplate(templateName));

    if (listModel.containsTemplate(templateName) && !confirmDialog(
            "Are you sure you want to overwrite the existing template named \"" + templateName + "\"?")) {
        return;
    }

    JmsConnectorProperties template = new JmsConnectorProperties();
    template.setUseJndi(useJndiYes.isSelected());
    template.setJndiProviderUrl(providerUrlField.getText());
    template.setJndiInitialContextFactory(initialContextFactoryField.getText());
    template.setJndiConnectionFactoryName(connectionFactoryNameField.getText());
    template.setConnectionFactoryClass(connectionFactoryClassField.getText());
    template.setConnectionProperties(connectionPropertiesTable.getProperties());

    try {
        parent.mirthClient.getServlet(JmsConnectorServletInterface.class).saveTemplate(templateName, template);
    } catch (Exception e) {
        parent.alertThrowable(parent, e);
        return;
    }

    listModel.putTemplate(templateName, template);
    templateList.setSelectedValue(templateName, true);
}

From source file:au.com.jwatmuff.eventmanager.gui.main.LoadCompetitionWindow.java

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

    selected = (DatabaseInfo) competitionList.getSelectedValue();
    if (selected == null)
        return;/*from www. j a v  a 2  s  .co m*/
    if (!Main.VERSION.equals(selected.version)) {
        GUIUtils.displayError(this, "This competition is only compatible with version " + selected.version
                + ".\nThis copy of EventManager is version " + Main.VERSION + ".");
        return;
    }

    String newName = (String) JOptionPane.showInputDialog(null, "Enter a new competition name",
            "Rename Competition", JOptionPane.PLAIN_MESSAGE, null, null, selected.name);

    if (newName != null) {
        Properties props = new Properties();
        props.setProperty("UUID", "" + selected.id);
        props.setProperty("name", newName);
        props.setProperty("password", "" + selected.passwordHash);
        props.setProperty("version", selected.version);

        File infoFile = new File(selected.localDirectory, "info.dat");

        try {
            props.store(new FileOutputStream(infoFile), null);
        } catch (IOException e) {
            log.error("Unable to write database info to file", e);
        }
        checkDatabasesExecutor.schedule(checkDatabasesTask, 0, TimeUnit.MILLISECONDS);
    }
}

From source file:game.Clue.ClueGameUI.java

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    // TODO add your handling code here:
    //Make A suggestion
    Object[] list_characters = { "MR.Green", "Mr.Peacock", "Mrs.White", "Mr.Plum", "Scarlet",
            "Colonel Mustard" };
    Object[] list_weapons = { "Candlestick", "Knife", "Wrench", "Lead Pipe", "Revolver", "Rope" };
    String m = (String) JOptionPane.showInputDialog(this, "Who do you think is the murderer?", "Solved It???",
            JOptionPane.PLAIN_MESSAGE, null, list_characters, "");
    String w = (String) JOptionPane.showInputDialog(this, "What weapon did they use?", "Solved It???",
            JOptionPane.PLAIN_MESSAGE, null, list_weapons, "");
    //String w = (String) JOptionPane.showInputDialog(this, "What was the murder weapon?","", JOptionPane.PLAIN_MESSAGE);

}

From source file:velocitekProStartAnalyzer.MainWindow.java

private String showSetStartTimeDialog() {
    Object[] hoursInPoints = {};//w w  w . ja  v  a2s .c  o m

    String time = "Checking";
    for (PointDto pointDto : JDBCPointDao.points) {
        if (!time.equals(
                pointDto.getPointDateHHmmss().substring(0, pointDto.getPointDateHHmmss().length() - 3))) {
            time = pointDto.getPointDateHHmmss();
            time = time.substring(0, time.length() - 3);
            hoursInPoints = appendValue(hoursInPoints, time);
        }

    }

    String s = (String) JOptionPane.showInputDialog(frame, "Choose start time:\n" + "hh:mm", "Time Chooser",
            JOptionPane.PLAIN_MESSAGE, null, hoursInPoints, null);
    return s;

}

From source file:convcao.com.agent.ConvcaoNeptusInteraction.java

@Override
public void initSubPanel() {
    jPanelMain = new JPanel();
    jPanel1 = new JPanel();
    jPanel2 = new JPanel();
    jLabel2 = new JLabel();
    jScrollPane1 = new JScrollPane();
    jTextPane1 = new JTextPane();
    renewButton = new JButton();
    jLabel4 = new JLabel();
    jTextField1 = new JTextField();
    jLabel5 = new JLabel();
    jPasswordField1 = new JPasswordField();
    connectButton = new JButton();
    jScrollPane2 = new JScrollPane();
    jTextArea1 = new JTextArea();
    jLabel7 = new JLabel();
    jLabel8 = new JLabel();
    jButton1 = new JButton();
    jButton2 = new JButton();
    jLabel1 = new JLabel();
    jLabel9 = new JLabel();
    jLabel10 = new JLabel();
    jLabel11 = new JLabel();
    jLabel12 = new JLabel();
    jLabel6 = new JLabel();
    jLabel3 = new JLabel();

    jLabel11.setIcon(noptilusLogo);//  ww w  . j a v  a  2s.c o  m

    jLabel12.setHorizontalAlignment(SwingConstants.LEFT);
    jLabel12.setText("<html>www.convcao.com<br>version 0.01</html>");
    jLabel12.setToolTipText("");
    jLabel12.setHorizontalTextPosition(SwingConstants.RIGHT);

    GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(jLabel11, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(GroupLayout.Alignment.TRAILING,
                    jPanel1Layout.createSequentialGroup().addGap(0, 19, Short.MAX_VALUE).addComponent(jLabel12,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                    .addComponent(jLabel11, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel12,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)));

    jLabel2.setFont(new Font("Tahoma", 0, 10)); // NOI18N
    jLabel2.setText("Unique ID");

    jTextPane1.setEditable(true);
    jScrollPane1.setViewportView(jTextPane1);
    //jTextPane1.getAccessibleContext().setAccessibleName("");

    renewButton.setText("RENEW");
    renewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            renewButtonActionPerformed(evt);
        }
    });

    jLabel4.setFont(new Font("Tahoma", 0, 12)); // NOI18N
    jLabel4.setText("Username");

    jTextField1.setText("FTPUser");

    jLabel5.setFont(new Font("Tahoma", 0, 12)); // NOI18N
    jLabel5.setText("Password");

    jPasswordField1.setText("FTPUser123");

    connectButton.setText("Connect");
    connectButton.setEnabled(false);
    connectButton.setActionCommand("connect");
    connectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                connectButtonActionPerformed(evt);
            } catch (FileNotFoundException | UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (SocketException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });

    jTextArea1.setEditable(false);
    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    jScrollPane2.setViewportView(jTextArea1);

    jLabel7.setFont(new Font("Tahoma", 0, 12)); // NOI18N
    jLabel7.setText("Command Monitor");

    jButton1.setFont(new Font("Tahoma", 1, 12)); // NOI18N
    jButton1.setText("START");
    jButton1.setEnabled(false);
    jButton1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            startButtonActionPerformed(evt);
        }
    });

    jButton2.setFont(new Font("Tahoma", 1, 12)); // NOI18N
    jButton2.setText("STOP");
    jButton2.setEnabled(false);
    jButton2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            stopButtonActionPerformed(evt);
        }
    });

    jLabel1.setForeground(new Color(255, 0, 0));
    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
    jLabel1.setText(
            "<html>Click HERE to activate the web service using your ID<br>When the web application is ready, press Start </html>");
    jLabel1.setCursor(new Cursor(Cursor.HAND_CURSOR));
    jLabel1.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            try {
                jLabel1MouseClicked(evt);
            } catch (URISyntaxException | IOException e) {
                e.printStackTrace();
            }
        }
    });

    //jLabel9.setText("Working...");
    jLabel9.setIcon(runIcon);
    jLabel9.setVisible(false);

    jLabel10.setText("---");

    jLabel6.setForeground(new Color(0, 204, 0));
    jLabel6.setHorizontalAlignment(SwingConstants.CENTER);
    jLabel6.setText("---");

    GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
            GroupLayout.Alignment.TRAILING,
            jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
                    .createParallelGroup(GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addComponent(jLabel6,
                            GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                            .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel2Layout.createSequentialGroup().addGap(126, 126, 126)
                                            .addComponent(jLabel7, GroupLayout.PREFERRED_SIZE, 110,
                                                    GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel2Layout.createSequentialGroup().addGap(23, 23, 23)
                                            .addGroup(jPanel2Layout
                                                    .createParallelGroup(GroupLayout.Alignment.TRAILING)
                                                    .addGroup(jPanel2Layout
                                                            .createParallelGroup(GroupLayout.Alignment.LEADING,
                                                                    false)
                                                            .addGroup(GroupLayout.Alignment.TRAILING,
                                                                    jPanel2Layout.createSequentialGroup()
                                                                            .addComponent(jLabel9,
                                                                                    GroupLayout.PREFERRED_SIZE,
                                                                                    56,
                                                                                    GroupLayout.PREFERRED_SIZE)
                                                                            .addPreferredGap(
                                                                                    LayoutStyle.ComponentPlacement.RELATED,
                                                                                    GroupLayout.DEFAULT_SIZE,
                                                                                    Short.MAX_VALUE)
                                                                            .addComponent(jButton1,
                                                                                    GroupLayout.PREFERRED_SIZE,
                                                                                    80,
                                                                                    GroupLayout.PREFERRED_SIZE)
                                                                            .addGap(29, 29, 29)
                                                                            .addComponent(jButton2,
                                                                                    GroupLayout.PREFERRED_SIZE,
                                                                                    77,
                                                                                    GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(jScrollPane2,
                                                                    GroupLayout.Alignment.TRAILING,
                                                                    GroupLayout.PREFERRED_SIZE, 308,
                                                                    GroupLayout.PREFERRED_SIZE))
                                                    .addComponent(jLabel10, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 103,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 299,
                                                            GroupLayout.PREFERRED_SIZE))))
                            .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                            .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                                    GroupLayout.Alignment.TRAILING,
                                    jPanel2Layout.createSequentialGroup()
                                            .addComponent(jLabel2, GroupLayout.PREFERRED_SIZE, 80,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18)
                                            .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 130,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18).addComponent(renewButton))
                                    .addGroup(GroupLayout.Alignment.TRAILING,
                                            jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
                                                    .createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                                            .addComponent(jLabel4, GroupLayout.PREFERRED_SIZE,
                                                                    64, GroupLayout.PREFERRED_SIZE)
                                                            .addGap(18, 18, 18).addComponent(jTextField1,
                                                                    GroupLayout.PREFERRED_SIZE, 130,
                                                                    GroupLayout.PREFERRED_SIZE))
                                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                                            .addComponent(jLabel5, GroupLayout.PREFERRED_SIZE,
                                                                    64, GroupLayout.PREFERRED_SIZE)
                                                            .addGap(18, 18, 18).addComponent(jPasswordField1)))
                                                    .addGap(14, 14, 14).addComponent(connectButton)))))
                    .addContainerGap()));
    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                            .addComponent(renewButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(jScrollPane1)
                            .addComponent(jLabel2, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(jTextField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(jPasswordField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(connectButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jLabel6, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel1)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel7, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jButton2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(jButton1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(jLabel9, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel10, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
                    .addGap(5, 5, 5)));

    jLabel1.getAccessibleContext().setAccessibleName("jLabel1");

    jLabel3.setFont(new Font("Tahoma", 1, 22)); // NOI18N
    jLabel3.setText("Real Time Navigation");

    jLabel8.setIcon(appLogo);

    GroupLayout layout = new GroupLayout(jPanelMain);
    jPanelMain.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel3)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(jLabel8, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jPanel2, GroupLayout.PREFERRED_SIZE, 331, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addComponent(jLabel3)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel8, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jPanel1,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addContainerGap()));

    addMenuItem("Settings>Noptilus>Coordinate Settings",
            ImageUtils.getIcon(PluginUtils.getPluginIcon(getClass())), new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    PluginUtils.editPluginProperties(coords, true);
                    coords.saveProps();
                }
            });

    addMenuItem("Settings>Noptilus>ConvCAO Settings", ImageUtils.getIcon(PluginUtils.getPluginIcon(getClass())),
            new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    PluginUtils.editPluginProperties(ConvcaoNeptusInteraction.this, true);
                }
            });

    addMenuItem("Settings>Noptilus>Force vehicle depth",
            ImageUtils.getIcon(PluginUtils.getPluginIcon(getClass())), new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    if (positions.isEmpty()) {
                        GuiUtils.errorMessage(getConsole(), "Force vehicle depth",
                                "ConvCAO control is not active");
                        return;
                    }
                    String[] choices = nameTable.values().toArray(new String[0]);

                    String vehicle = (String) JOptionPane.showInputDialog(getConsole(), "Force vehicle depth",
                            "Choose vehicle", JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);

                    if (vehicle != null) {
                        double depth = depths.get(vehicle);
                        String newDepth = JOptionPane.showInputDialog(getConsole(), "New depth", "" + depth);
                        try {
                            double dd = Double.parseDouble(newDepth);
                            depths.put(vehicle, dd);
                        } catch (Exception ex) {
                            GuiUtils.errorMessage(getConsole(), ex);
                        }
                    }
                }
            });

    add(jPanelMain);

    renewButtonActionPerformed(null);
}

From source file:velocitekProStartAnalyzer.MainWindow.java

private String showSetEndTimeDialog() {
    Object[] hoursInPoints = {};//from w  w  w  .  ja v a 2s  .  co  m

    String time = "Checking";
    for (PointDto pointDto : JDBCPointDao.points) {
        if (!time.equals(
                pointDto.getPointDateHHmmss().substring(0, pointDto.getPointDateHHmmss().length() - 3))) {
            time = pointDto.getPointDateHHmmss();
            time = time.substring(0, time.length() - 3);
            hoursInPoints = appendValue(hoursInPoints, time);
        }

    }

    String s = (String) JOptionPane.showInputDialog(frame, "Choose end time:\n" + "hh:mm", "Set end time",
            JOptionPane.PLAIN_MESSAGE, null, hoursInPoints, null);
    return s;

}