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:au.org.ala.delta.ui.MessageDialogHelper.java

/**
 * Uses JOptionPane.showInputDialog to display the supplied (multi-line) message and return the
 * user input.//from w w  w.  j a  v  a  2s  . c om
 * @param parent the parent component used to display the JOptionPane.
 * @param title the title for the option pane.
 * @param text the message text to display on the option pane.  Multi-line messages should 
 * use the "\n" character.
 * @param numColumns the column position to wrap the text at.
 * @param initialValue the initial value for the user input.
 * @return the value supplied to the JOptionPane input dialog.
 */
public static String showInputDialog(Component parent, String title, String text, int numColumns,
        String initialValue) {

    JTextArea messageDisplay = createMessageDisplay(text, numColumns);
    return (String) JOptionPane.showInputDialog(parent, messageDisplay, title, JOptionPane.PLAIN_MESSAGE, null,
            null, initialValue);
}

From source file:de.weltraumschaf.minesweeper.control.VersionInfoListener.java

@Override
public void actionPerformed(final ActionEvent e) {
    JOptionPane.showMessageDialog(main, String.format("Version: %s", version.toString()), main.getTitle(),
            JOptionPane.PLAIN_MESSAGE);
}

From source file:Main.java

public void actionPerformed(ActionEvent e) {
    String menuText = ((JMenuItem) e.getSource()).getText();
    int messageType = JOptionPane.INFORMATION_MESSAGE;
    if (menuText.equals("Information")) {
        messageType = JOptionPane.INFORMATION_MESSAGE;
    } else if (menuText.equals("Warning")) {
        messageType = JOptionPane.WARNING_MESSAGE;
    } else if (menuText.equals("Error")) {
        messageType = JOptionPane.ERROR_MESSAGE;
    } else if (menuText.equals("Plain")) {
        messageType = JOptionPane.PLAIN_MESSAGE;
    }//from  www  . j a va 2 s.co  m

    JOptionPane.showMessageDialog(myFrame, "This is message dialog box of type: " + menuText,
            menuText + " Message", messageType);
}

From source file:ch.zhaw.parallelComputing.view.Plotter.java

/**
 * Displays a plot of the given data sets as a dialog with a save as PNG option
 * @param parent component to set the dialog relative to
 * @param title the name of the Plot and the header of the dialog
 * @param dataset1 the first data set for plotting
 * @param dataset2 the second data set for plotting
 *//*from   w w w .j  av a 2  s .com*/
public static void plotWithDialog(Component parent, String title, XYDataset dataset1, XYDataset dataset2) {
    JFreeChart chart = plot(title, dataset1, dataset2);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1024, 768));
    chartPanel.setMouseZoomable(true, false);

    String[] options = { "Print", "OK" };
    int response = JOptionPane.showOptionDialog(parent // Center in window.
            , chartPanel, title // Title in titlebar
            , JOptionPane.YES_NO_OPTION // Option type
            , JOptionPane.PLAIN_MESSAGE // messageType
            , null // Icon (none)
            , options // Button text as above.
            , "OK" // Default button
    );

    if (response == 0) {
        getPlotAsPNG(title, dataset1, dataset2);
    }
}

From source file:mysynopsis.FTPUploader.java

public static void display() throws IOException {

    JTextField address = new JTextField(server);
    JTextField username = new JTextField(user);
    JPasswordField password = new JPasswordField(pass);
    JTextField directory = new JTextField(dir);

    JPanel panel = new JPanel(new GridLayout(10, 1));
    panel.add(new JLabel("Server Address:"));
    panel.add(address);//www  .  j av  a  2 s. c om
    panel.add(new JLabel("Username:"));
    panel.add(username);
    panel.add(new JLabel("Password:"));
    panel.add(password);
    panel.add(new JLabel("Upload Directory:"));
    panel.add(directory);

    int result;

    /*JOptionPane pane = new JOptionPane(panel,JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION);
    JDialog dialog = pane.createDialog(MotherFrame.mframe, "FTP Upload Wizard - My Synopsis");
    dialog.setSize(new Dimension(300,300));
    dialog.setVisible(true);*/

    result = JOptionPane.showConfirmDialog(MotherFrame.mframe, panel, "FTP Upload Wizard",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

    if (result == JOptionPane.OK_OPTION) {

        server = address.getText();
        user = username.getText();
        pass = new String(password.getPassword());
        //    System.out.println(pass);
        dir = directory.getText();

        JOptionPane.showMessageDialog(MotherFrame.mframe, "Press OK to start FTP Upload");

        HTMLWriter.writeHTML();

        JOptionPane.showMessageDialog(MotherFrame.mframe, uploadWizard());

    } else {
        //  System.out.println("Cancelled");
    }
}

From source file:me.mayo.telnetkek.player.PlayerCommandEntry.java

public String buildOutput(PlayerInfo player, boolean useReasonPrompt) {
    String output = StringUtils.replaceEach(getFormat(),
            new String[] { "$TARGET_NAME", "$TARGET_IP", "$TARGET_UUID", },
            new String[] { player.getName(), player.getIp(), player.getUuid() });

    if (useReasonPrompt && output.contains("$REASON")) {
        final String reason = StringUtils.trimToEmpty(JOptionPane.showInputDialog(null,
                "Input reason:\n" + output, "Input Reason", JOptionPane.PLAIN_MESSAGE));
        output = StringUtils.replace(output, "$REASON", reason);
    }// w  w  w . j  av a  2s . c o  m

    return StringUtils.trimToEmpty(output);
}

From source file:com.qspin.qtaste.testapi.impl.generic.UtilityImpl.java

public void showMessageDialog(final String title, final String message) throws QTasteException {
    try {//from   w  w w . j a  v a  2s  .  c o  m
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(null, message, title, JOptionPane.PLAIN_MESSAGE);
            }
        });
    } catch (Exception e) {
        throw new QTasteException("Error while showing message dialog", e);
    }
}

From source file:net.itransformers.topologyviewer.menu.handlers.graphTools.shortherstPathMenuHandlers.DijkstraWeightedShortestPathMenuHandler.java

@Override
public void actionPerformed(ActionEvent e) {
    final GraphViewerPanel viewerPanel = (GraphViewerPanel) frame.getTabbedPane().getSelectedComponent();
    final MyVisualizationViewer vv = (MyVisualizationViewer) viewerPanel.getVisualizationViewer();

    Collection<String> vertices = viewerPanel.getCurrentGraph().getVertices();
    String[] test = vertices.toArray(new String[0]);
    Arrays.sort(test);//from w ww.  ja v  a 2s.c  o  m

    final String mFrom = (String) JOptionPane.showInputDialog(frame, "Choose A Node", "A Node",
            JOptionPane.PLAIN_MESSAGE, null, test, test[0]);
    final String mTo = (String) JOptionPane.showInputDialog(frame, "Choose B Node", "B Node",
            JOptionPane.PLAIN_MESSAGE, null, test, test[0]);
    String weightedKey = JOptionPane.showInputDialog(frame, "Enter Weighted Key", "Weighted Key",
            JOptionPane.QUESTION_MESSAGE);

    Transformer<String, Double> wtTransformer = new Transformer<String, Double>() {
        public Double transform(String edgeId) {

            return null;
        }
    };

    final Graph<String, String> mGraph = viewerPanel.getCurrentGraph();
    DijkstraShortestPath<String, String> alg = new DijkstraShortestPath(mGraph, wtTransformer);

    final List<String> mPred = alg.getPath(mFrom, mTo);
    //        System.out.println("The shortest unweighted path from" + mFrom +" to " + mTo + " is:");
    //        System.out.println(mPred.toString());

    if (mPred == null) {
        JOptionPane.showMessageDialog(frame,
                String.format("Shortest path between %s,%s is not found", mFrom, mTo), "Message",
                JOptionPane.INFORMATION_MESSAGE);
        return;
    }

    final Layout<String, String> layout = vv.getGraphLayout();
    for (final String edge : layout.getGraph().getEdges()) {
        if (mPred.contains(edge)) {
            vv.setEdgeStroke(edge, new BasicStroke(4f));

        }

    }
}

From source file:de.dakror.virtualhub.client.dialog.ChooseCatalogDialog.java

public static void show(ClientFrame frame, final JSONArray data) {
    final JDialog dialog = new JDialog(frame, "Katalog whlen", true);
    dialog.setSize(400, 300);/*from   w  w w .  java 2s  .  c  o  m*/
    dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            Client.currentClient.disconnect();
            System.exit(0);
        }
    });

    JPanel contentPane = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    dialog.setContentPane(contentPane);
    DefaultListModel dlm = new DefaultListModel();
    for (int i = 0; i < data.length(); i++) {
        try {
            dlm.addElement(data.getJSONObject(i).getString("name"));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    final JList catalogs = new JList(dlm);
    catalogs.setDragEnabled(false);
    catalogs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JScrollPane jsp = new JScrollPane(catalogs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jsp.setPreferredSize(new Dimension(396, 200));
    contentPane.add(jsp);

    JPanel mods = new JPanel(new GridLayout(1, 2));
    mods.setPreferredSize(new Dimension(50, 22));
    mods.add(new JButton(new AbstractAction("+") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            String name = JOptionPane.showInputDialog(dialog,
                    "Bitte geben Sie den Namen des neuen Katalogs ein.", "Katalog hinzufgen",
                    JOptionPane.PLAIN_MESSAGE);
            if (name != null && name.length() > 0) {
                DefaultListModel dlm = (DefaultListModel) catalogs.getModel();
                for (int i = 0; i < dlm.getSize(); i++) {
                    if (dlm.get(i).toString().equals(name)) {
                        JOptionPane.showMessageDialog(dialog,
                                "Es existert bereits ein Katalog mit diesem Namen!",
                                "Katalog bereits vorhanden!", JOptionPane.ERROR_MESSAGE);
                        actionPerformed(e);
                        return;
                    }
                }

                try {
                    dlm.addElement(name);
                    JSONObject o = new JSONObject();
                    o.put("name", name);
                    o.put("sources", new JSONArray());
                    o.put("tags", new JSONArray());
                    data.put(o);
                    Client.currentClient.sendPacket(new Packet0Catalogs(data));
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    }));
    mods.add(new JButton(new AbstractAction("-") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (catalogs.getSelectedIndex() != -1) {
                if (JOptionPane.showConfirmDialog(dialog,
                        "Sind Sie sicher, dass Sie diesen\r\nKatalog unwiderruflich lschen wollen?",
                        "Katalog lschen", JOptionPane.YES_NO_CANCEL_OPTION,
                        JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
                    DefaultListModel dlm = (DefaultListModel) catalogs.getModel();
                    data.remove(catalogs.getSelectedIndex());
                    dlm.remove(catalogs.getSelectedIndex());
                    try {
                        Client.currentClient.sendPacket(new Packet0Catalogs(data));
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        }
    }));

    contentPane.add(mods);

    JLabel l = new JLabel("");
    l.setPreferredSize(new Dimension(396, 14));
    contentPane.add(l);

    JSeparator sep = new JSeparator(JSeparator.HORIZONTAL);
    sep.setPreferredSize(new Dimension(396, 10));
    contentPane.add(sep);

    JPanel buttons = new JPanel(new GridLayout(1, 2));
    buttons.setPreferredSize(new Dimension(396, 22));
    buttons.add(new JButton(new AbstractAction("Abbrechen") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            Client.currentClient.disconnect();
            System.exit(0);
        }
    }));
    buttons.add(new JButton(new AbstractAction("Katalog whlen") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (catalogs.getSelectedIndex() != -1) {
                try {
                    Client.currentClient
                            .setCatalog(new Catalog(data.getJSONObject(catalogs.getSelectedIndex())));
                    Client.currentClient.frame.setTitle("- " + Client.currentClient.getCatalog().getName());
                    dialog.dispose();
                } catch (JSONException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }));

    dialog.add(buttons);

    dialog.setLocationRelativeTo(frame);
    dialog.setResizable(false);
    dialog.setVisible(true);
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopComponentsHelper.java

public static int convertNotificationType(com.haulmont.cuba.gui.components.Frame.NotificationType type) {
    switch (type) {
    case WARNING:
    case WARNING_HTML:
        return JOptionPane.WARNING_MESSAGE;
    case ERROR:// w  w w  .j a va2  s . c o m
    case ERROR_HTML:
        return JOptionPane.ERROR_MESSAGE;
    case HUMANIZED:
    case HUMANIZED_HTML:
        return JOptionPane.INFORMATION_MESSAGE;
    case TRAY:
    case TRAY_HTML:
        return JOptionPane.WARNING_MESSAGE;
    default:
        return JOptionPane.PLAIN_MESSAGE;
    }
}