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

public static String showInputDialog(Component parentComponent, Object message, Object initialSelectionValue) 

Source Link

Document

Shows a question-message dialog requesting input from the user and parented to parentComponent.

Usage

From source file:com.raddle.tools.MergeMain.java

private void updatePropertyLine(PropertyLine pl) {
    if (pl != null) {
        if (pl.getState() == LineState.deleted) {
            JOptionPane.showMessageDialog(MergeMain.this, pl.getKey() + "?");
        } else {/*from w  w  w.j  a v  a  2  s  .c  o m*/
            StringBuilder sb = new StringBuilder();
            sb.append(": ");
            if (pl.getComment() != null) {
                sb.append(pl.getComment());
            }
            sb.append('\n');
            sb.append(": " + pl.getKey()).append('\n');
            ;
            sb.append(": " + StringUtils.defaultString(pl.getOriginalValue()));
            String v = JOptionPane.showInputDialog(MergeMain.this, sb.toString(), pl.getValue());
            if (v != null && !v.trim().equals(pl.getValue())) {
                if (pl.getState() != LineState.added && pl.getState() != LineState.deleted) {
                    pl.setState(LineState.updated);
                }
                pl.setValue(v);
                if (pl.getValue().equals(pl.getOriginalValue())) {
                    pl.setState(LineState.original);
                }
                compare();
            }
        }
    }
}

From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java

protected void chooseServer() {
    final TwoObjectsX<String, String> serverAndClientId = new TwoObjectsX<String, String>(
            iliasProperties.getIliasServerURL(), iliasProperties.getIliasClient());
    final boolean noConfigDoneYet = serverAndClientId.getObjectA() == null
            || serverAndClientId.getObjectA().trim().isEmpty();

    final JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    final JLabel labelServer = new JLabel("Server: " + serverAndClientId.getObjectA());
    final JLabel labelClientId = new JLabel("Client Id: " + serverAndClientId.getObjectB());

    JComboBox<LoginType> comboboxLoginType = null;
    JComboBox<DownloadMethod> comboboxDownloadMethod = null;

    final Runnable findOutClientId = new Runnable() {

        @Override//from  w  w  w. j a va 2s . c  o m
        public void run() {
            try {
                String s = IliasUtil.findClientByLoginPageOrWebserviceURL(serverAndClientId.getObjectA());
                serverAndClientId.setObjectB(s);
                labelClientId.setText("Client Id: " + s);
            } catch (Exception e1) {
                showError("Client Id konnte nicht ermittelt werden", e1);
            }
        }
    };

    final Runnable promptInputServer = new Runnable() {

        @Override
        public void run() {

            String s = JOptionPane.showInputDialog(panel,
                    "Geben Sie die Ilias Loginseitenadresse oder Webserviceadresse ein",
                    serverAndClientId.getObjectA());
            if (s != null) {
                try {
                    s = IliasUtil.findSOAPWebserviceByLoginPage(s.trim());

                    if (!s.toLowerCase().startsWith("https://")) {
                        JOptionPane.showMessageDialog(mainFrame,
                                "Achtung! Die von Ihnen angegebene Adresse beginnt nicht mit 'https://'.\nDie Verbindung ist daher nicht ausreichend gesichert. Ein Angreifer knnte Ihre Ilias Daten und Ihr Passwort abgreifen",
                                "Achtung, nicht geschtzt", JOptionPane.WARNING_MESSAGE);
                    }

                    serverAndClientId.setObjectA(s);
                    labelServer.setText("Server: " + serverAndClientId.getObjectA());

                    if (noConfigDoneYet) {
                        findOutClientId.run();
                    }
                } catch (IliasException e1) {
                    showError(
                            "Bitte geben Sie die Adresse der Ilias Loginseite oder die des Webservice an. Die Adresse der Loginseite muss 'login.php' enthalten",
                            e1);
                }
            }
        }
    };

    {
        JPanel panel2 = new JPanel(new BorderLayout());

        panel2.add(labelServer, BorderLayout.NORTH);
        panel2.add(labelClientId, BorderLayout.SOUTH);

        panel.add(panel2, BorderLayout.NORTH);
    }
    {
        JPanel panel2 = new JPanel(new BorderLayout());

        JPanel panel3 = new JPanel(new GridLayout());
        {
            JButton b = new JButton("Server ndern");
            b.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    promptInputServer.run();
                }
            });
            panel3.add(b);

            b = new JButton("Client Id ndern");
            b.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    String s = JOptionPane.showInputDialog(panel, "Client Id eingeben",
                            serverAndClientId.getObjectB());
                    if (s != null) {
                        serverAndClientId.setObjectB(s);
                        labelClientId.setText("Client Id: " + serverAndClientId.getObjectB());
                    }

                }
            });
            panel3.add(b);

            b = new JButton("Client Id automatisch ermitteln");
            b.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    findOutClientId.run();
                }
            });
            panel3.add(b);
        }
        panel2.add(panel3, BorderLayout.NORTH);

        panel3 = new JPanel(new GridLayout(0, 2, 5, 2));
        {
            panel3.add(new JLabel("Loginmethode: "));
            comboboxLoginType = new JComboBox<LoginType>();
            FunctionsX.setComboBoxLayoutString(comboboxLoginType, new ObjectDoInterface<LoginType, String>() {

                @Override
                public String doSomething(LoginType loginType) {
                    switch (loginType) {
                    case DEFAULT:
                        return "Standard";
                    case LDAP:
                        return "LDAP";
                    case CAS:
                        return "CAS";
                    default:
                        return "<Fehler>";
                    }
                }

            });
            val model = ((DefaultComboBoxModel<LoginType>) comboboxLoginType.getModel());
            for (LoginType loginType : LoginType.values()) {
                model.addElement(loginType);
            }
            model.setSelectedItem(iliasProperties.getLoginType());
            panel3.add(comboboxLoginType);

            JLabel label = new JLabel("Dateien herunterladen ber:");
            label.setToolTipText("Die restliche Kommunikation luft immer ber den SOAP Webservice");
            panel3.add(label);
            comboboxDownloadMethod = new JComboBox<DownloadMethod>();
            FunctionsX.setComboBoxLayoutString(comboboxDownloadMethod,
                    new ObjectDoInterface<DownloadMethod, String>() {

                        @Override
                        public String doSomething(DownloadMethod downloadMethod) {
                            switch (downloadMethod) {
                            case WEBSERVICE:
                                return "SOAP Webservice (Standard)";
                            case WEBDAV:
                                return "WEBDAV";
                            default:
                                return "<Fehler>";
                            }
                        }

                    });
            val model2 = ((DefaultComboBoxModel<DownloadMethod>) comboboxDownloadMethod.getModel());
            for (DownloadMethod downloadMethod : DownloadMethod.values()) {
                model2.addElement(downloadMethod);
            }
            model2.setSelectedItem(iliasProperties.getDownloadMethod());
            panel3.add(comboboxDownloadMethod);
        }
        panel2.add(panel3, BorderLayout.WEST);

        panel.add(panel2, BorderLayout.SOUTH);
    }

    if (noConfigDoneYet) {
        promptInputServer.run();
    }

    if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Server konfigurieren",
            JOptionPane.OK_CANCEL_OPTION)) {
        if (syncService != null) {
            syncService.logoutIfLoggedIn();
        }
        iliasProperties.setIliasServerURL(serverAndClientId.getObjectA());
        iliasProperties.setIliasClient(serverAndClientId.getObjectB());
        iliasProperties.setLoginType((LoginType) comboboxLoginType.getSelectedItem());
        iliasProperties.setDownloadMethod((DownloadMethod) comboboxDownloadMethod.getSelectedItem());
        saveProperties(iliasProperties);
        updateTitleCaption();
    }

}

From source file:com.raddle.tools.MergeMain.java

private String inputEditorCmd() {
    String cmd = properties.getProperty("editor.cmd");
    if (StringUtils.isBlank(cmd)) {
        String osName = System.getProperties().getProperty("os.name");
        if (osName.toLowerCase().indexOf("windows") != -1) {
            cmd = "notepad {0}";
        } else {/*from ww  w  . ja v  a  2 s .  co m*/
            cmd = "gedit {0}";
        }
    }
    String input = JOptionPane.showInputDialog(MergeMain.this, ",{0}",
            cmd);
    if (StringUtils.isNotBlank(input)) {
        properties.setProperty("editor.cmd", input);
        savePropMergeFile();
    }
    return input;
}

From source file:edu.ku.brc.specify.tasks.RecordSetTask.java

/**
 * @param intialName//from  www.j  a  v a  2  s  .com
 * @return
 */
public String getUniqueRecordSetName(final String intialName) {
    String rsName = null;
    DBFieldInfo fi = DBTableIdMgr.getInstance().getInfoById(RecordSet.getClassTableId())
            .getFieldByColumnName("Name");
    int maxLen = fi == null ? 64 : fi.getLength();
    do {
        rsName = JOptionPane.showInputDialog(UIRegistry.get(UIRegistry.FRAME),
                getResourceString("RecordSetTask.ASKFORNAME") + ":", intialName);
        if (rsName == null) {
            UIRegistry.displayStatusBarText("");
            return null;
        }

        if (!UIHelper.isValidNameForDB(rsName)) {
            UIRegistry.displayLocalizedStatusBarError("INVALID_CHARS_NAME");
            UIRegistry.displayErrorDlgLocalized("INVALID_CHARS_NAME");
            Toolkit.getDefaultToolkit().beep();
            continue;
        }

        if (rsName.length() > maxLen) {
            UIRegistry.displayStatusBarErrMsg(
                    String.format(UIRegistry.getResourceString("RecordSetTask.RS_NAME_TOO_LONG"), maxLen));
            UIRegistry.displayErrorDlg(
                    String.format(UIRegistry.getResourceString("RecordSetTask.RS_NAME_TOO_LONG"), maxLen));
            Toolkit.getDefaultToolkit().beep();
            continue;
        }

        rsName = UIHelper.escapeName(rsName);

        rsName = StringUtils.replace(rsName, "\"", "`");

        DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
        try {
            String sql = String.format(
                    "SELECT count(*) FROM RecordSet rs INNER JOIN rs.specifyUser spu WHERE rs.name = '%s' AND rs.collectionMemberId = COLLID AND spu.specifyUserId = SPECIFYUSERID",
                    rsName);
            sql = QueryAdjusterForDomain.getInstance().adjustSQL(sql);
            Object obj = session.getData(sql);
            if (obj instanceof Integer) {
                if (((Integer) obj) == 0) {
                    UIRegistry.displayStatusBarText("");
                    return rsName;
                }

            } else {
                throw new RuntimeException("Return value should have been an Integer!");
            }
            UIRegistry.displayErrorDlg(String.format(getResourceString("RecordSetTask.RS_NAME_DUP"), rsName));
            UIRegistry.getStatusBar()
                    .setErrorMessage(String.format(getResourceString("RecordSetTask.RS_NAME_DUP"), rsName));
            Toolkit.getDefaultToolkit().beep();

        } catch (Exception ex) {
            ex.printStackTrace();
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(RecordSetTask.class, ex);
            //log.error(ex);

        } finally {
            session.close();
        }
    } while (rsName != null);

    return null;
}

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

private void attachRaceSeriesFile(Type type) throws IOException, EntityNotFoundException {
    DataObject raceSeriesOrFleet = chooseRaceSeriesOrFleet();
    if (raceSeriesOrFleet != null) {
        File file = openFile(RACEATTACHDIR, null, null);
        if (file != null) {
            String title = JOptionPane.showInputDialog(frame, TextUtil.getText("TITLE"),
                    TextUtil.getText(type.name()));
            if (title != null) {
                dss.upload(raceSeriesOrFleet, type, title, file);
            }/*from   w  w  w .  ja  v a 2s .c o m*/
        }
    }
}

From source file:com.dfki.av.sudplan.ui.MainFrame.java

private void miAddWMSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miAddWMSActionPerformed
    String server = JOptionPane.showInputDialog(this, "WMS URL",
            "http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/germany/germany.map&&VERSION=1.1.1&REQUEST=GetCapabilities&SERVICE=WMS");
    try {//from  w w  w . ja v  a 2 s.co  m
        if (server == null) {
            log.debug("Cancled JOptionPane.");
            return;
        }
        if (server.isEmpty()) {
            String msg = "Server URL is empty";
            log.error(msg);
            throw new IllegalArgumentException(msg);
        }
        final URI serverURI = new URI(server.trim());
        wwPanel.addAllWMSLayer(serverURI);
    } catch (Exception ex) {
        log.error(ex.getMessage());
        JOptionPane.showMessageDialog(this, ex.toString(), "Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:gda.plots.SimplePlot.java

/**
 * Creates the JPopupMenu, overrides (but uses) the super class method adding items for the Magnification and
 * Logarithmic axes./*from  ww  w  .j a  v  a  2s  . c  om*/
 * 
 * @param properties
 *            boolean if true appears on menu
 * @param save
 *            boolean if true appears on menu
 * @param print
 *            boolean if true appears on menu
 * @param zoom
 *            boolean if true appears on menu
 * @return the popup menu
 */
@Override
protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) {
    // Create the popup without the zooming parts
    JPopupMenu jpm = super.createPopupMenu(properties, false, print, false);

    // as the save function on the chartpanel doesn't remember its location,
    // we shall remove it and and create a new save option
    if (save) {
        jpm.add(new JSeparator());

        // The save button

        saveButton = new JMenuItem("Save As");
        saveButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                saveAs();
            }
        });

        jpm.add(saveButton);
    }

    jpm.add(new JSeparator());

    // This button toggles the data-type magnification
    magnifyDataButton = new JCheckBoxMenuItem("Magnify(Data)");
    magnifyDataButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setMagnifyingData(!isMagnifyingData());
        }
    });
    jpm.add(magnifyDataButton);

    jpm.add(new JSeparator());

    // The zoomButton toggles the value of zooming.
    zoomButton = new JCheckBoxMenuItem("Zoom");
    zoomButton.setHorizontalTextPosition(SwingConstants.LEFT);
    zoomButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setZooming(!isZooming());
        }
    });
    jpm.add(zoomButton);

    // The unZoomButton is not a toggle, it undoes the last zoom.
    unZoomButton = new JMenuItem("UnZoom");
    unZoomButton.setEnabled(false);
    unZoomButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            unZoom();
        }
    });
    jpm.add(unZoomButton);

    if (type == LINECHART) {
        jpm.add(new JSeparator());

        turboModeButton = new JCheckBoxMenuItem("Turbo Mode");
        turboModeButton.setHorizontalTextPosition(SwingConstants.LEFT);
        turboModeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                setTurboMode(!isTurboMode());
            }
        });
        turboModeButton.setSelected(isTurboMode());
        jpm.add(turboModeButton);

        stripModeButton = new JCheckBoxMenuItem("StripChart Mode");
        stripModeButton.setHorizontalTextPosition(SwingConstants.LEFT);
        stripModeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String widthStr = "";
                {
                    double width = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getLength()
                            : Double.MAX_VALUE;
                    widthStr = getXAxisNumberFormat().format(width);
                    widthStr = JOptionPane.showInputDialog(null,
                            "Enter the x strip width - clear for autorange", widthStr);
                    if (widthStr == null) //cancel
                        return;
                }
                Double newStripWidth = null;
                if (!widthStr.isEmpty()) {
                    try {
                        newStripWidth = Double.valueOf(widthStr);
                    } catch (Exception ex) {
                        logger.error(ex.getMessage(), ex);
                    }
                }
                setStripWidth(newStripWidth);
            }
        });
        stripModeButton.setSelected(isStripMode());
        jpm.add(stripModeButton);

        xLimitsButton = new JCheckBoxMenuItem("Fix X Axis Limits");
        xLimitsButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String minStr = "";
                {
                    double min = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getLowerBound()
                            : Double.MAX_VALUE;
                    minStr = getXAxisNumberFormat().format(min);
                    minStr = JOptionPane.showInputDialog(null, "Enter the min x value - clear for autorange",
                            minStr);
                    if (minStr == null) //cancel
                        return;

                }
                String maxStr = "";
                if (!minStr.isEmpty()) {
                    double max = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getUpperBound()
                            : -Double.MAX_VALUE;
                    maxStr = getXAxisNumberFormat().format(max);
                    maxStr = JOptionPane.showInputDialog(null, "Enter the max x value - clear for autorange",
                            maxStr);
                    if (maxStr == null) //cancel
                        return;
                }
                Range newBounds = null;
                if (!maxStr.isEmpty() && !minStr.isEmpty()) {
                    try {
                        newBounds = new Range(Double.valueOf(minStr), Double.valueOf(maxStr));
                    } catch (Exception ex) {
                        logger.error(ex.getMessage(), ex);
                    }
                }
                setDomainBounds(newBounds);
            }
        });
        xLimitsButton.setSelected(false);
        jpm.add(xLimitsButton);

    }

    jpm.add(new JSeparator());

    xLogLinButton = new JMenuItem("Logarithmic X axis");
    xLogLinButton.setEnabled(true);
    xLogLinButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setXAxisLogarithmic(!isXAxisLogarithmic());
        }
    });
    jpm.add(xLogLinButton);

    yLogLinButton = new JMenuItem("Logarithmic Y axis");
    yLogLinButton.setEnabled(true);
    yLogLinButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setYAxisLogarithmic(!isYAxisLogarithmic());
        }
    });
    jpm.add(yLogLinButton);

    y2LogLinButton = new JMenuItem("Logarithmic Y2 axis");
    y2LogLinButton.setEnabled(false);
    y2LogLinButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setYAxisTwoLogarithmic(!isYAxisTwoLogarithmic());
        }
    });

    jpm.add(y2LogLinButton);

    jpm.add(new JSeparator());

    // Adding a new button to allow the user to select the formatting they
    // want on the x and y axis
    xFormatButton = new JMenuItem("X Axis Format");
    xFormatButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String Format = getXAxisNumberFormat().format(0.0);
            String input = JOptionPane.showInputDialog(null,
                    "Enter the new formatting for the X axis, of the form 0.0000E00", Format);
            // try forcing this into some objects
            try {
                setScientificXAxis(new DecimalFormat(input));
            } catch (Exception err) {
                logger.error("Could not use this format due to {}", e);
            }
        }
    });
    jpm.add(xFormatButton);

    // Adding a new button to allow the user to select the formatting they
    // want on the x and y axis
    yFormatButton = new JMenuItem("Y Axis Format");
    yFormatButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String Format = getYAxisNumberFormat().format(0.0);
            String input = JOptionPane.showInputDialog(null,
                    "Enter the new formatting for the Y axis, of the form 0.0000E00", Format);
            // try forcing this into some objects
            try {
                setScientificYAxis(new DecimalFormat(input));
            } catch (Exception err) {
                logger.error("Could not use this format due to {}", e);
            }
        }
    });
    jpm.add(yFormatButton);

    // The zoomButton toggles the value of zooming.
    xAxisVerticalTicksButton = new JCheckBoxMenuItem("Vertical X Ticks");
    xAxisVerticalTicksButton.setHorizontalTextPosition(SwingConstants.LEFT);
    xAxisVerticalTicksButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVerticalXAxisTicks(xAxisVerticalTicksButton.isSelected());
        }
    });
    jpm.add(xAxisVerticalTicksButton);

    return jpm;
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java

/**
 * Abre uma URL/*from  www. j  a v a2 s . c o m*/
 * 
 */
private void abreUrl() {
    String url;
    url = JOptionPane.showInputDialog(this, GERAL.DIGITE_ENDERECO, "http://");
    PegarPaginaWEB ppw = new PegarPaginaWEB();
    if (url != null) {
        // arquivo=null;
        try {
            String codHtml = ppw.getContent(url);
            // boxCode.setText(codHtml);
            // reavalia(codHtml);
            parentFrame.showPainelFerramentaDescricaoPArq(codHtml);
            EstadoSilvinha.setLinkAtual(url);
        } catch (HttpException e1) {
            JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_NAO_CONECTOU,
                    TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE);
        } catch (Exception e1) {
            JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_VERIFIQUE_URL,
                    TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE);
        }
    }
}

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

private void addReferencePayments() throws EntityNotFoundException {
    while (true) {
        String reference = "";
        CreditorReference cr = null;/*ww w.  j a  va2  s  .  c o m*/
        while (true) {
            reference = JOptionPane.showInputDialog(frame, TextUtil.getText("REFERENCE"), reference);
            if (reference == null) {
                return;
            }
            try {
                cr = new CreditorReference(reference, true);
                break;
            } catch (IllegalArgumentException ex) {
                JOptionPane.showMessageDialog(frame, ex);
            }
        }
        int rn = Integer.parseInt(reference.substring(0, reference.length() - 1));
        RaceEntry raceEntry = dss.raceEntryForReference(rn);
        Double fee = (Double) raceEntry.get(RaceEntry.FEE);
        String fieldsAsHtmlTable = raceEntry.getFieldsAsHtmlTable(RaceEntry.FLEET, RaceEntry.HELMNAME,
                RaceEntry.HELMADDRESS, RaceEntry.CLUB, RaceEntry.HELMEMAIL, RaceEntry.HELMPHONE, RaceEntry.FEE,
                RaceEntry.PAID);
        String paidStr = JOptionPane.showInputDialog(frame, "<html>" + fieldsAsHtmlTable + "</html>", fee);
        if (paidStr != null) {
            try {
                fee = Double.parseDouble(paidStr);
            } catch (NumberFormatException ex) {
                continue;
            }
            raceEntry.set(RaceEntry.PAID, fee);
            dss.put(raceEntry);
        }
    }
}

From source file:net.panthema.BispanningGame.GamePanel.java

public void addPopupActions(JPopupMenu popup) {

    popup.add(new AbstractAction("Center Graph") {
        private static final long serialVersionUID = 571719411574657791L;

        public void actionPerformed(ActionEvent e) {
            centerAndScaleGraph();/*from  w ww  . j a  v  a 2 s  .c  om*/
        }
    });

    popup.add(new AbstractAction("Relayout Graph") {
        private static final long serialVersionUID = 571719411573657791L;

        public void actionPerformed(ActionEvent e) {
            relayoutGraph();
        }
    });

    popup.add(new AbstractAction("Reset Board Colors") {
        private static final long serialVersionUID = 571719411573657796L;

        public void actionPerformed(ActionEvent e) {
            mGraph.updateOriginalColor();
            mTurnNum = 0;
            putLog("Resetting game graph's colors.");
            updateGraphMessage();
            mVV.repaint();
        }
    });

    popup.add(new AbstractAction(
            allowFreeExchange ? "Restrict to Unique Exchanges" : "Allow Free Edge Exchanges") {
        private static final long serialVersionUID = 571719411573657798L;

        public void actionPerformed(ActionEvent e) {
            allowFreeExchange = !allowFreeExchange;
            mVV.repaint();
        }
    });

    popup.add(new AbstractAction((mAutoPlayBob ? "Disable" : "Enable") + " Autoplay of Bob's Moves") {
        private static final long serialVersionUID = 571719413573657798L;

        public void actionPerformed(ActionEvent e) {
            mAutoPlayBob = !mAutoPlayBob;
        }
    });

    popup.addSeparator();

    JMenu newGraph = new JMenu("New Random Graph");
    for (int i = 0; i < actionRandomGraph.length; ++i) {
        if (actionRandomGraph[i] != null)
            newGraph.add(actionRandomGraph[i]);
    }
    newGraph.addSeparator();
    newGraph.add(getActionNewGraphType());
    popup.add(newGraph);

    JMenu newNamedGraph = new JMenu("New Named Graph");
    for (int i = 0; i < actionNamedGraph.size(); ++i) {
        if (actionNamedGraph.get(i) != null)
            newNamedGraph.add(actionNamedGraph.get(i));
    }
    popup.add(newNamedGraph);

    popup.add(new AbstractAction("Show GraphString") {
        private static final long serialVersionUID = 545719411573657792L;

        public void actionPerformed(ActionEvent e) {
            JEditorPane text = new JEditorPane("text/plain",
                    GraphString.write_graph(mGraph, mVV.getModel().getGraphLayout()));
            text.setEditable(false);
            text.setPreferredSize(new Dimension(300, 125));
            JOptionPane.showMessageDialog(null, text, "GraphString Serialization",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    });

    popup.add(new AbstractAction("Load GraphString") {
        private static final long serialVersionUID = 8636579131902717983L;

        public void actionPerformed(ActionEvent e) {
            String input = JOptionPane.showInputDialog(null, "Enter GraphString:", "");
            if (input == null)
                return;
            loadGraphString(input);
        }
    });

    popup.add(new AbstractAction("Show graph6") {
        private static final long serialVersionUID = 571719411573657792L;

        public void actionPerformed(ActionEvent e) {
            JTextArea text = new JTextArea(Graph6.write_graph6(mGraph));
            JOptionPane.showMessageDialog(null, text, "graph6 Serialization", JOptionPane.INFORMATION_MESSAGE);
        }
    });

    popup.add(new AbstractAction("Load graph6/sparse6") {
        private static final long serialVersionUID = 571719411573657792L;

        public void actionPerformed(ActionEvent e) {
            String input = JOptionPane.showInputDialog(null, "Enter graph6/sparse6 string:", "");
            if (input == null)
                return;
            MyGraph g = Graph6.read_graph6(input);
            setNewGraph(g);
        }
    });

    popup.add(new AbstractAction("Read GraphML") {
        private static final long serialVersionUID = 571719411573657794L;

        public void actionPerformed(ActionEvent e) {
            try {
                readGraphML();
            } catch (IOException e1) {
                showStackTrace(e1);
            } catch (GraphIOException e1) {
                showStackTrace(e1);
            }
        }
    });

    popup.add(new AbstractAction("Write GraphML") {
        private static final long serialVersionUID = 571719411573657795L;

        public void actionPerformed(ActionEvent e) {
            try {
                writeGraphML();
            } catch (IOException e1) {
                showStackTrace(e1);
            }
        }
    });

    popup.add(new AbstractAction("Write PDF") {
        private static final long serialVersionUID = 571719411573657793L;

        public void actionPerformed(ActionEvent e) {
            try {
                writePdf();
            } catch (FileNotFoundException e1) {
                showStackTrace(e1);
            } catch (DocumentException de) {
                System.err.println(de.getMessage());
            }
        }
    });
}