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:com.neurotec.samples.panels.EnrollFromScanner.java

private void identifyPatient() throws IOException, JSONException {

    service = new FingerPrintService(
            (Applet) this.getParent().getParent().getParent().getParent().getParent().getParent().getParent());

    //1. make server call to get java.util.List<PatientFingerPrintModel> patientModels
    this.patients = service.getAllPatients();

    //2. enroll the patientModels
    this.enrollFingerPrints(patients);

    //3.identify the patient id
    String patientID = this.identifyFinger();

    //4. set the patient view
    PatientFingerPrintModel patient = getPatientByUUID(patientID);
    if (patient != null) {
        service.updatePatientListView(patient);
    } else {//from  www. j  a  va  2  s .c om
        btnRegisterPatient.setEnabled(true);
        JOptionPane.showMessageDialog(this, "Patient Not Found", "Identification", JOptionPane.PLAIN_MESSAGE);

    }
}

From source file:com.igormaznitsa.sciareto.ui.UiUtils.java

public static boolean msgOkCancel(@Nonnull final String title, @Nonnull final Object component) {
    return JOptionPane.showConfirmDialog(Main.getApplicationFrame(), component, title,
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null) == JOptionPane.OK_OPTION;
}

From source file:com.frostwire.gui.library.LibraryUtils.java

public static void createNewPlaylist(final File[] files, final boolean starred) {

    final StringBuilder plBuilder = new StringBuilder();

    GUIMediator.safeInvokeAndWait(new Runnable() {

        @Override//from  w w  w.  j  av  a 2s  .  co m
        public void run() {
            String input = (String) JOptionPane.showInputDialog(GUIMediator.getAppFrame(),
                    I18n.tr("Playlist name"), I18n.tr("Playlist name"), JOptionPane.PLAIN_MESSAGE, null, null,
                    calculateName(files));
            if (!StringUtils.isNullOrEmpty(input, true)) {
                plBuilder.append(input);
            }
        }
    });

    String playlistName = plBuilder.toString();

    if (playlistName != null && playlistName.length() > 0) {
        GUIMediator.instance().setWindow(GUIMediator.Tabs.LIBRARY);
        final Playlist playlist = LibraryMediator.getLibrary().newPlaylist(playlistName, playlistName);
        playlist.save();

        GUIMediator.safeInvokeLater(new Runnable() {

            @Override
            public void run() {
                LibraryMediator.instance().getLibraryPlaylists().addPlaylist(playlist);
                LibraryMediator.instance().getLibraryPlaylists().markBeginImport(playlist);
            }
        });

        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    Set<File> ignore = TorrentUtil.getIgnorableFiles();
                    addToPlaylist(playlist, files, starred, ignore);
                    playlist.save();
                } finally {
                    asyncAddToPlaylistFinalizer(playlist);
                }
            }
        }, "createNewPlaylist");
        t.setDaemon(true);
        t.start();
    }
}

From source file:net.pms.newgui.SelectRenderers.java

/**
 * Create the GUI and show it.//  www.  j  a  v a  2s  . c o  m
 */
public void showDialog() {
    if (!init) {
        // Initial call
        build();
        init = true;
    }
    SrvTree.validate();
    // Refresh setting if modified
    selectedRenderers = configuration.getSelectedRenderers();
    TreePath root = new TreePath(allRenderers);
    if (selectedRenderers.isEmpty() || (selectedRenderers.size() == 1 && selectedRenderers.get(0) == null)) {
        checkTreeManager.getSelectionModel().clearSelection();
    } else if (selectedRenderers.size() == 1 && selectedRenderers.get(0).equals(allRenderersTreeName)) {
        checkTreeManager.getSelectionModel().setSelectionPath(root);
    } else {
        if (root.getLastPathComponent() instanceof SearchableMutableTreeNode) {
            SearchableMutableTreeNode rootNode = (SearchableMutableTreeNode) root.getLastPathComponent();
            SearchableMutableTreeNode node = null;
            List<TreePath> selectedRenderersPath = new ArrayList<>(selectedRenderers.size());
            for (String selectedRenderer : selectedRenderers) {
                try {
                    node = rootNode.findInBranch(selectedRenderer, true);
                } catch (IllegalChildException e) {
                }
                if (node != null) {
                    selectedRenderersPath.add(new TreePath(node.getPath()));
                }
            }
            checkTreeManager.getSelectionModel().setSelectionPaths(
                    selectedRenderersPath.toArray(new TreePath[selectedRenderersPath.size()]));
        } else {
            LOGGER.error("Illegal node class in SelectRenderers.showDialog(): {}",
                    root.getLastPathComponent().getClass().getSimpleName());
        }
    }

    int selectRenderers = JOptionPane.showOptionDialog((Component) PMS.get().getFrame(), this,
            Messages.getString("GeneralTab.5"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null,
            null, null);

    if (selectRenderers == JOptionPane.OK_OPTION) {
        TreePath[] selected = checkTreeManager.getSelectionModel().getSelectionPaths();
        if (selected.length == 0) {
            if (configuration.setSelectedRenderers("")) {
                PMS.get().getFrame().setReloadable(true); // notify the user to restart the server
            }
        } else if (selected.length == 1
                && selected[0].getLastPathComponent() instanceof SearchableMutableTreeNode
                && ((SearchableMutableTreeNode) selected[0].getLastPathComponent()).getNodeName()
                        .equals(allRenderers.getNodeName())) {
            if (configuration.setSelectedRenderers(allRenderersTreeName)) {
                PMS.get().getFrame().setReloadable(true); // notify the user to restart the server
            }
        } else {
            List<String> selectedRenderers = new ArrayList<>();
            for (TreePath path : selected) {
                String rendererName = "";
                if (path.getPathComponent(0).equals(allRenderers)) {
                    for (int i = 1; i < path.getPathCount(); i++) {
                        if (path.getPathComponent(i) instanceof SearchableMutableTreeNode) {
                            if (!rendererName.isEmpty()) {
                                rendererName += " ";
                            }
                            rendererName += ((SearchableMutableTreeNode) path.getPathComponent(i))
                                    .getNodeName();
                        } else {
                            LOGGER.error("Invalid tree node component class {}",
                                    path.getPathComponent(i).getClass().getSimpleName());
                        }
                    }
                    if (!rendererName.isEmpty()) {
                        selectedRenderers.add(rendererName);
                    }
                } else {
                    LOGGER.warn("Invalid renderer treepath encountered: {}", path.toString());
                }
            }
            if (configuration.setSelectedRenderers(selectedRenderers)) {
                PMS.get().getFrame().setReloadable(true); // notify the user to restart the server
            }
        }
    }
}

From source file:net.sourceforge.processdash.ev.ui.ScheduleBalancingDialog.java

private void buildAndShowGUI() {
    chartData = null;//from   w  ww  .  j a va2 s  .  c  o m
    int numScheduleRows = scheduleRows.size();

    sumUpTotalTime();
    originalTotalTime = totalRow.time;
    if (originalTotalTime == 0)
        // if the rows added up to zero, choose a nominal target total time
        // corresponding to 10 hours per included schedule
        originalTotalTime = numScheduleRows * 60 * 10;

    JPanel panel = new JPanel(new GridBagLayout());
    if (numScheduleRows == 1) {
        totalRow.rowLabel = scheduleRows.get(0).rowLabel;
    } else {
        for (int i = 0; i < numScheduleRows; i++)
            scheduleRows.get(i).addToPanel(panel, i);
        scheduleRows.get(numScheduleRows - 1).showPercentageTickMarks();
        addChartToPanel(panel, numScheduleRows + 1);
    }
    totalRow.addToPanel(panel, numScheduleRows);

    if (rowsAreEditable == false) {
        String title = TaskScheduleDialog.resources.getString("Balance.Read_Only_Title");
        JOptionPane.showMessageDialog(parent.frame, panel, title, JOptionPane.PLAIN_MESSAGE);

    } else {
        String title = TaskScheduleDialog.resources.getString("Balance.Editable_Title");
        JDialog dialog = new JDialog(parent.frame, title, true);
        addButtons(dialog, panel, numScheduleRows + 2);
        panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        dialog.getContentPane().add(panel);
        dialog.pack();
        dialog.setLocationRelativeTo(parent.frame);
        dialog.setResizable(true);
        dialog.setVisible(true);
    }
}

From source file:com.jostrobin.battleships.view.frames.GameFrame.java

public void showWinnerDialog() {
    JOptionPane.showMessageDialog(this, "You have won", "Game End", JOptionPane.PLAIN_MESSAGE);
}

From source file:coolmap.canvas.datarenderer.renderer.impl.NumberComposite.java

public NumberComposite() {

    setName("Number to Composite");
    //        System.out.println("Created a new NumberComposite");
    setDescription("A renderer that can be used to assign renderers to different aggregations");

    configUI.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;//from www . j a  va2  s  .co  m
    c.gridy = 0;
    c.ipadx = 5;
    c.ipady = 5;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridwidth = 1;

    //This combo box will need to be able to add registered
    singleComboBox = new JComboBox();
    rowComboBox = new JComboBox();
    columnComboBox = new JComboBox();
    rowColumnComboBox = new JComboBox();

    singleLegend = new JLabel();
    rowLegend = new JLabel();
    columnLegend = new JLabel();
    rowColumnLegend = new JLabel();

    singleLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    rowLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    columnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    rowColumnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    //Add them
    JLabel label = new JLabel("Default:");
    label.setToolTipText("Default renderer");
    c.gridx = 0;
    c.gridy++;
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(singleComboBox, c);
    singleComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 2;
    JButton config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (singleRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    singleRenderer.getConfigUI(), "Default Renderer Config", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(singleLegend, c);

    //////////////////////////////////////////////////////////////
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Row Group:");
    label.setToolTipText("Renderer for row ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(rowComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (rowGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    rowGroupRenderer.getConfigUI(), "Row Group Renderer Config", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }

        }
    });
    rowComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(rowLegend, c);

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Column Group:");
    label.setToolTipText("Renderer for column ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(columnComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (columnGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    columnGroupRenderer.getConfigUI(), "Column Group Renderer Config",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(columnLegend, c);
    columnComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Row & Column Group:");
    label.setToolTipText("Renderer for row and column ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(rowColumnComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (rowColumnGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    rowColumnGroupRenderer.getConfigUI(), "Row + Column Group Renderer Config",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });
    rowColumnComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(rowColumnLegend, c);

    JButton button = new JButton("Apply Changes", UI.getImageIcon("refresh"));
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateRenderer();
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    configUI.add(button, c);

    singleComboBox.setRenderer(new ComboRenderer());
    rowComboBox.setRenderer(new ComboRenderer());
    columnComboBox.setRenderer(new ComboRenderer());
    rowColumnComboBox.setRenderer(new ComboRenderer());

    _updateLists();

}

From source file:com.jostrobin.battleships.view.frames.GameFrame.java

public void showWinnerDialog(String username) {
    JOptionPane.showMessageDialog(this, username + " has won", "Game End", JOptionPane.PLAIN_MESSAGE);
}

From source file:com.t3.macro.api.functions.input.InputFunctions.java

/**
 * <pre>//from w w w .  j  a va  2s  .  c  om
 * <span style="font-family:sans-serif;">The input() function prompts the user to input several variable values at once.
 * 
 * Each of the string parameters has the following format:
 *     "varname|value|prompt|inputType|options"
 * 
 * Only the first section is required.
 *     varname   - the variable name to be assigned
 *     value     - sets the initial contents of the input field
 *     prompt    - UI text shown for the variable
 *     inputType - specifies the type of input field
 *     options   - a string of the form "opt1=val1; opt2=val2; ..."
 * 
 * The inputType field can be any of the following (defaults to TEXT):
 *     TEXT  - A text field.
 *             "value" sets the initial contents.
 *             The return value is the string in the text field.
 *             Option: WIDTH=nnn sets the width of the text field (default 16).
 *     LIST  - An uneditable combo box.
 *             "value" populates the list, and has the form "item1,item2,item3..." (trailing empty strings are dropped)
 *             The return value is the numeric index of the selected item.
 *             Option: SELECT=nnn sets the initial selection (default 0).
 *             Option: VALUE=STRING returns the string contents of the selected item (default NUMBER).
 *             Option: TEXT=FALSE suppresses the text of the list item (default TRUE).
 *             Option: ICON=TRUE causes icon asset URLs to be extracted from the "value" and displayed (default FALSE).
 *             Option: ICONSIZE=nnn sets the size of the icons (default 50).
 *     CHECK - A checkbox.
 *             "value" sets the initial state of the box (anything but "" or "0" checks the box)
 *             The return value is 0 or 1.
 *             No options.
 *     RADIO - A group of radio buttons.
 *             "value" is a list "name1, name2, name3, ..." which sets the labels of the buttons.
 *             The return value is the index of the selected item.
 *             Option: SELECT=nnn sets the initial selection (default 0).
 *             Option: ORIENT=H causes the radio buttons to be laid out on one line (default V).
 *             Option: VALUE=STRING causes the return value to be the string of the selected item (default NUMBER).
 *     LABEL - A label.
 *             The "varname" is ignored and no value is assigned to it.
 *             Option: TEXT=FALSE, ICON=TRUE, ICONSIZE=nnn, as in the LIST type.
 *     PROPS - A sub-panel with multiple text boxes.
 *             "value" contains a StrProp of the form "key1=val1; key2=val2; ..."
 *             One text box is created for each key, populated with the matching value.
 *             Option: SETVARS=SUFFIXED causes variable assignment to each key name, with appended "_" (default NONE).
 *             Option: SETVARS=UNSUFFIXED causes variable assignment to each key name.
 *     TAB   - A tabbed dialog tab is created.  Subsequent variables are contained in the tab.
 *             Option: SELECT=TRUE causes this tab to be shown at start (default SELECT=FALSE).
 * 
 *  All inputTypes except TAB accept the option SPAN=TRUE, which causes the prompt to be hidden and the input
 *  control to span both columns of the dialog layout (default FALSE).
 * </span>
 * </pre>
 * @param parameters a list of strings containing information as described above
 * @return a HashMap with the returned values or null if the user clicked on cancel
 * @author knizia.fan
 * @throws MacroException 
 */
public static Map<String, String> input(TokenView token, String... parameters) throws MacroException {
    // Extract the list of specifier strings from the parameters
    // "name | value | prompt | inputType | options"
    List<String> varStrings = new ArrayList<String>();
    for (Object param : parameters) {
        String paramStr = (String) param;
        if (StringUtils.isEmpty(paramStr)) {
            continue;
        }
        // Multiple vars can be packed into a string, separated by "##"
        for (String varString : StringUtils.splitByWholeSeparator(paramStr, "##")) {
            if (StringUtils.isEmpty(paramStr)) {
                continue;
            }
            varStrings.add(varString);
        }
    }

    // Create VarSpec objects from each variable's specifier string
    List<VarSpec> varSpecs = new ArrayList<VarSpec>();
    for (String specifier : varStrings) {
        VarSpec vs;
        try {
            vs = new VarSpec(specifier);
        } catch (VarSpec.SpecifierException se) {
            throw new MacroException(se);
        } catch (InputType.OptionException oe) {
            throw new MacroException(I18N.getText("macro.function.input.invalidOptionType", oe.key, oe.value,
                    oe.type, specifier));
        }
        varSpecs.add(vs);
    }

    // Check if any variables were defined
    if (varSpecs.isEmpty())
        return Collections.emptyMap(); // No work to do, so treat it as a successful invocation.

    // UI step 1 - First, see if a token is given

    String dialogTitle = "Input Values";
    if (token != null) {
        String name = token.getName(), gm_name = token.getGMName();
        boolean isGM = TabletopTool.getPlayer().isGM();
        String extra = "";

        if (isGM && gm_name != null && gm_name.compareTo("") != 0)
            extra = " for " + gm_name;
        else if (name != null && name.compareTo("") != 0)
            extra = " for " + name;

        dialogTitle = dialogTitle + extra;
    }

    // UI step 2 - build the panel with the input fields
    InputPanel ip = new InputPanel(varSpecs);

    // Calculate the height
    // TODO: remove this workaround
    int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
    int maxHeight = screenHeight * 3 / 4;
    Dimension ipPreferredDim = ip.getPreferredSize();
    if (maxHeight < ipPreferredDim.height) {
        ip.modifyMaxHeightBy(maxHeight - ipPreferredDim.height);
    }

    // UI step 3 - show the dialog
    JOptionPane jop = new JOptionPane(ip, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    JDialog dlg = jop.createDialog(TabletopTool.getFrame(), dialogTitle);

    // Set up callbacks needed for desired runtime behavior
    dlg.addComponentListener(new FixupComponentAdapter(ip));

    dlg.setVisible(true);
    int dlgResult = JOptionPane.CLOSED_OPTION;
    try {
        dlgResult = (Integer) jop.getValue();
    } catch (NullPointerException npe) {
    }
    dlg.dispose();

    if (dlgResult == JOptionPane.CANCEL_OPTION || dlgResult == JOptionPane.CLOSED_OPTION)
        return null;

    HashMap<String, String> results = new HashMap<String, String>();

    // Finally, assign values from the dialog box to the variables
    for (ColumnPanel cp : ip.columnPanels) {
        List<VarSpec> panelVars = cp.varSpecs;
        List<JComponent> panelControls = cp.inputFields;
        int numPanelVars = panelVars.size();
        StringBuilder allAssignments = new StringBuilder(); // holds all values assigned in this tab

        for (int varCount = 0; varCount < numPanelVars; varCount++) {
            VarSpec vs = panelVars.get(varCount);
            JComponent comp = panelControls.get(varCount);
            String newValue = null;
            switch (vs.inputType) {
            case TEXT: {
                newValue = ((JTextField) comp).getText();
                break;
            }
            case LIST: {
                Integer index = ((JComboBox) comp).getSelectedIndex();
                if (vs.optionValues.optionEquals("VALUE", "STRING")) {
                    newValue = vs.valueList.get(index);
                } else { // default is "NUMBER"
                    newValue = index.toString();
                }
                break;
            }
            case CHECK: {
                Integer value = ((JCheckBox) comp).isSelected() ? 1 : 0;
                newValue = value.toString();
                break;
            }
            case RADIO: {
                // This code assumes that the Box container returns components
                // in the same order that they were added.
                Component[] comps = ((Box) comp).getComponents();
                int componentCount = 0;
                Integer index = 0;
                for (Component c : comps) {
                    if (c instanceof JRadioButton) {
                        JRadioButton radio = (JRadioButton) c;
                        if (radio.isSelected())
                            index = componentCount;
                    }
                    componentCount++;
                }
                if (vs.optionValues.optionEquals("VALUE", "STRING")) {
                    newValue = vs.valueList.get(index);
                } else { // default is "NUMBER"
                    newValue = index.toString();
                }
                break;
            }
            case LABEL: {
                newValue = null;
                // The variable name is ignored and not set.
                break;
            }
            case PROPS: {
                // Read out and assign all the subvariables.
                // The overall return value is a property string (as in StrPropFunctions.java) with all the new settings.
                Component[] comps = ((JPanel) comp).getComponents();
                StringBuilder sb = new StringBuilder();
                int setVars = 0; // "NONE", no assignments made
                if (vs.optionValues.optionEquals("SETVARS", "SUFFIXED"))
                    setVars = 1;
                if (vs.optionValues.optionEquals("SETVARS", "UNSUFFIXED"))
                    setVars = 2;
                if (vs.optionValues.optionEquals("SETVARS", "TRUE"))
                    setVars = 2; // for backward compatibility
                for (int compCount = 0; compCount < comps.length; compCount += 2) {
                    String key = ((JLabel) comps[compCount]).getText().split("\\:")[0]; // strip trailing colon
                    String value = ((JTextField) comps[compCount + 1]).getText();
                    sb.append(key);
                    sb.append("=");
                    sb.append(value);
                    sb.append(" ; ");
                    switch (setVars) {
                    case 0:
                        // Do nothing
                        break;
                    case 1:
                        results.put(key + "_", value);
                        break;
                    case 2:
                        results.put(key, value);
                        break;
                    }
                }
                newValue = sb.toString();
                break;
            }
            default:
                // should never happen
                newValue = null;
                break;
            }
            // Set the variable to the value we got from the dialog box.
            if (newValue != null) {
                results.put(vs.name, newValue.trim());
                allAssignments.append(vs.name + "=" + newValue.trim() + " ## ");
            }
        }
        if (cp.tabVarSpec != null) {
            results.put(cp.tabVarSpec.name, allAssignments.toString());
        }
    }

    return results; // success

    // for debugging:
    //return debugOutput(varSpecs);
}

From source file:com.smart.aqimonitor.client.AqiMonitor.java

/**
 * Create the frame.//from   www  .  ja  v  a2  s  . co  m
 */
public AqiMonitor() {
    refSelf = this;
    setPreferredSize(new Dimension(640, 480));
    setTitle("\u7A7A\u6C14\u8D28\u91CF\u76D1\u6D4B");
    setIconImage(Toolkit.getDefaultToolkit()
            .getImage(AqiMonitor.class.getResource("/lombok/installer/eclipse/STS.png")));
    setMinimumSize(new Dimension(640, 480));
    setMaximumSize(new Dimension(1024, 768));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 636, 412);
    contentPane = new JPanel();
    contentPane.setPreferredSize(new Dimension(640, 480));
    contentPane.setMinimumSize(new Dimension(640, 480));
    contentPane.setMaximumSize(new Dimension(1024, 768));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JPanel mainPanel = new JPanel();
    contentPane.add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(new BorderLayout(0, 0));

    JPanel contentPanel = new JPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane
            .setViewportBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    contentPanel.add(scrollPane, BorderLayout.CENTER);

    textPane = new AqiTextPane();
    textPane.addInputMethodListener(new InputMethodListener() {

        public void caretPositionChanged(InputMethodEvent event) {

        }

        public void inputMethodTextChanged(InputMethodEvent event) {
            textPane.setCaretPosition(document.getLength() + 1);
        }
    });
    textPane.setEditable(false);
    textPane.setOpaque(false);
    textPane.setForeground(Color.BLACK);
    scrollPane.setViewportView(textPane);
    document = textPane.getStyledDocument();

    document.addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            if (e.getDocument() == document) {
                textPane.setCaretPosition(document.getLength());
            }
        }
    });

    JPanel buttonPanel = new JPanel();
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    buttonPanel.setLayout(new BorderLayout(0, 0));

    JLabel lblTipsLabel = new JLabel(
            "Tips\uFF1A\u6587\u4EF6\u4FDD\u5B58\u683C\u5F0Fcsv\u53EF\u7528Excel\u6253\u5F00");
    lblTipsLabel.setForeground(Color.BLUE);
    buttonPanel.add(lblTipsLabel, BorderLayout.WEST);

    JPanel panel = new JPanel();
    buttonPanel.add(panel, BorderLayout.CENTER);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton btnRetrieve = new JButton("\u624B\u52A8\u83B7\u53D6\u6570\u636E");
    panel.add(btnRetrieve);
    btnRetrieve.setVerticalAlignment(SwingConstants.BOTTOM);

    JButton btnNewButton = new JButton("\u5173\u4E8E");
    btnNewButton.setToolTipText("\u5173\u4E8E");
    btnNewButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JTextArea textArea = new JTextArea(
                    "\n        csv\n\n        smartstudio@foxmail.com");
            textArea.setColumns(35);
            textArea.setRows(6);
            textArea.setLineWrap(true);// 
            textArea.setEditable(false);// 
            textArea.setOpaque(false);
            JOptionPane.showMessageDialog(contentPane, textArea, "", JOptionPane.PLAIN_MESSAGE);
        }
    });

    JButton btnSetting = new JButton("\u8BBE\u7F6E");
    btnSetting.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            Point parentPos = refSelf.getLocation();

            AqiSettingDialog settingDialog = new AqiSettingDialog(refSelf, pm25InDetailJob.getAqiParser());
            settingDialog.setModal(true);
            settingDialog.setLocation(parentPos.x + 100, parentPos.y + 150);
            settingDialog.init();
            settingDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            settingDialog.setVisible(true);
        }
    });

    JButton btnExportDir = new JButton("\u67E5\u770B\u6570\u636E");
    btnExportDir.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {

                String[] cmd = new String[5];

                String filePath = pm25InDetailJob.getAqiParser().getFilePath();
                File file = new File(filePath);
                if (!file.exists()) {
                    FileUtil.makeDir(file);
                }
                if (!file.isDirectory()) {
                    JOptionPane.showMessageDialog(contentPane, "", "",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                cmd[0] = "cmd";
                cmd[1] = "/c";
                cmd[2] = "start";
                cmd[3] = " ";
                cmd[4] = pm25InDetailJob.getAqiParser().getFilePath();

                Runtime.getRuntime().exec(cmd);

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
    panel.add(btnExportDir);
    panel.add(btnSetting);
    panel.add(btnNewButton);
    btnRetrieve.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!isRetrieving) {
                isRetrieving = true;
                Thread firstRun = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        pm25InDetailJob.refresh();
                        isRetrieving = false;
                    }
                });

                firstRun.start();
            }
        }
    });

    init();
}