Example usage for javax.swing JOptionPane INFORMATION_MESSAGE

List of usage examples for javax.swing JOptionPane INFORMATION_MESSAGE

Introduction

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

Prototype

int INFORMATION_MESSAGE

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

Click Source Link

Document

Used for information messages.

Usage

From source file:model.settings.ReadSettings.java

/**
 * checks whether program information on current workspace exist.
 * @return if workspace is now set.//www .  j  av  a 2  s .co  m
 */
public static String install() {
    boolean installed = false;
    String wsLocation = "";
    /*
     * does program root directory exist?
     */
    if (new File(PROGRAM_LOCATION).exists()) {

        //try to read 
        try {
            wsLocation = readFromFile(PROGRAM_SETTINGS_LOCATION);

            installed = new File(wsLocation).exists();
            if (!installed) {
                wsLocation = "";
            }

        } catch (FileNotFoundException e) {
            System.out.println("file not found " + e);
            showErrorMessage();
        } catch (IOException e) {
            System.out.println("io" + e);
            showErrorMessage();
        }
    }

    //if settings not found.
    if (!installed) {

        new File(PROGRAM_LOCATION).mkdir();
        try {

            //create new file chooser
            JFileChooser jc = new JFileChooser();

            //sets the text and language of all the components in JFileChooser
            UIManager.put("FileChooser.openDialogTitleText", "Open");
            UIManager.put("FileChooser.lookInLabelText", "LookIn");
            UIManager.put("FileChooser.openButtonText", "Open");
            UIManager.put("FileChooser.cancelButtonText", "Cancel");
            UIManager.put("FileChooser.fileNameLabelText", "FileName");
            UIManager.put("FileChooser.filesOfTypeLabelText", "TypeFiles");
            UIManager.put("FileChooser.openButtonToolTipText", "OpenSelectedFile");
            UIManager.put("FileChooser.cancelButtonToolTipText", "Cancel");
            UIManager.put("FileChooser.fileNameHeaderText", "FileName");
            UIManager.put("FileChooser.upFolderToolTipText", "UpOneLevel");
            UIManager.put("FileChooser.homeFolderToolTipText", "Desktop");
            UIManager.put("FileChooser.newFolderToolTipText", "CreateNewFolder");
            UIManager.put("FileChooser.listViewButtonToolTipText", "List");
            UIManager.put("FileChooser.newFolderButtonText", "CreateNewFolder");
            UIManager.put("FileChooser.renameFileButtonText", "RenameFile");
            UIManager.put("FileChooser.deleteFileButtonText", "DeleteFile");
            UIManager.put("FileChooser.filterLabelText", "TypeFiles");
            UIManager.put("FileChooser.detailsViewButtonToolTipText", "Details");
            UIManager.put("FileChooser.fileSizeHeaderText", "Size");
            UIManager.put("FileChooser.fileDateHeaderText", "DateModified");
            SwingUtilities.updateComponentTreeUI(jc);

            jc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            jc.setMultiSelectionEnabled(false);

            final String informationMsg = "Please select the workspace folder. \n"
                    + "By default, the new files are saved in there. \n\n"
                    + "Is changed simply by using the Save-As option.\n"
                    + "If no folder is specified, the default worspace folder \n"
                    + "is the home directory of the current user.";
            final int response = JOptionPane.showConfirmDialog(jc, informationMsg, "Select workspace folder",
                    JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);

            final String defaultSaveLocation = System.getProperty("user.home")
                    + System.getProperty("file.separator");
            File f;
            if (response != JOptionPane.NO_OPTION) {

                //fetch selected file
                f = jc.getSelectedFile();
                jc.showDialog(null, "select");
            } else {
                f = new File(defaultSaveLocation);
            }

            printInformation();

            if (f == null) {
                f = new File(defaultSaveLocation);
            }
            //if file selected
            if (f != null) {

                //if the file exists
                if (f.exists()) {
                    writeToFile(PROGRAM_SETTINGS_LOCATION, ID_PROGRAM_LOCATION + "\n" + f.getAbsolutePath());
                } else {

                    //open message dialog
                    JOptionPane.showConfirmDialog(null, "Folder does " + "not exist",
                            "Error creating workspace", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
                            null);
                }

                //recall install
                return install();
            }

        } catch (IOException e) {
            System.out.println(e);
            JOptionPane.showConfirmDialog(null, "An exception occured." + " Try again later.",
                    "Error creating workspace", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null);
        }
    }

    if (System.getProperty("os.name").equals("Mac OS X")) {

        installOSX();
    } else if (System.getProperty("os.name").equals("Linux")) {
        installLinux();
    } else if (System.getProperty("os.name").equals("Windows")) {
        installWindows();
    }

    return wsLocation;

}

From source file:metodosnumericos.VentanaPuntoFijo.java

private void butCalcularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butCalcularActionPerformed
    if (txtGx.getText().isEmpty() || txtIteraciones.getText().isEmpty() || txtTolerancia.getText().isEmpty()
            || txtXa.getText().isEmpty()) {
        JOptionPane.showMessageDialog(null, "Verifique que los campos no esten vacios", "Mensaje",
                JOptionPane.INFORMATION_MESSAGE);
    } else {//from w ww.j  a va  2s  .  co m
        try {
            Graficador t = new Graficador();
            double tolerancia = Double.parseDouble(txtTolerancia.getText());
            int iteraciones = Integer.parseInt(txtIteraciones.getText());
            double xi = Double.parseDouble(txtXa.getText());
            String gx = txtGx.getText();

            Metodos m = new Metodos();
            JOptionPane.showMessageDialog(null, m.PuntoFijo(tolerancia, xi, iteraciones, funcion, gx, true),
                    "Resultado", JOptionPane.INFORMATION_MESSAGE);

            GeneradorTablas g = new GeneradorTablas();
            JTable tabla = g.tablaPuntoFijo(m.getPuntoFijoXn(), m.getPuntoFijoFxn(), m.getPuntoFijoEa(),
                    m.getPuntoFijoEr());

            double xs;
            //Si Xi < Xv
            if (xi < m.getPuntoFijoXn().get(m.getPuntoFijoXn().size() - 1).doubleValue()) {
                xs = m.getPuntoFijoXn().get(m.getPuntoFijoXn().size() - 1).doubleValue() + 5;
            } else {
                xs = xi;
                xi = m.getPuntoFijoXn().get(m.getPuntoFijoXn().size() - 1).doubleValue() - 5;
            }
            XYSeries series = t.series2(gx, "gx", xi, xs);
            XYSeries seriesx = t.series2("x", "X", xi, xs);
            XYSeriesCollection collection = new XYSeriesCollection(series);
            collection.addSeries(seriesx);
            JFreeChart chart = ChartFactory.createXYLineChart("Grafica", "X", "Y", collection);
            ChartPanel panel = new ChartPanel(chart);
            panel.setPreferredSize(new java.awt.Dimension(400, 300));

            panelGrafica.removeAll();
            panelGrafica.add(panel);
            panelGrafica.updateUI();

            panelTabla.removeAll();
            panelTabla.add(new JScrollPane(tabla));
            panelTabla.updateUI();

            VentanaUnaVariable vuv = new VentanaUnaVariable();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Verifique que los campos sean Numeros", "Mensaje",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    }

}

From source file:de.dakror.villagedefense.util.SaveHandler.java

public static void sendScore() {
    try {//w ww.j av a2s  .  c o  m
        if (isWorldScorePosted(Game.currentGame.worldCreated)) {
            JOptionPane.showMessageDialog(null,
                    "Du hast deinen Punktestand auf dieser Karte bereits in der Bestenliste platziert!",
                    "Bereits platziert!", JOptionPane.ERROR_MESSAGE);
            return;
        }

        String response = Helper
                .getURLContent(new URL("http://dakror.de/villagedefense/api/scores.php?USERNAME="
                        + urlencode(CFG.USERNAME) + "&SCORE=" + Game.currentGame.getPlayerScore()));
        System.out.println(response);
        if (!response.equals("false")) {
            JOptionPane.showMessageDialog(null,
                    "Dein Punktestand wurde erfolgreich in der Bestenliste platziert.",
                    "Platzieren erfolgreich!", JOptionPane.INFORMATION_MESSAGE);
            addWorldScorePosted(Game.currentGame.worldCreated);
            Game.currentGame.scoreSent = true;
        } else
            JOptionPane.showMessageDialog(null,
                    "Dein Punktestand konnte nicht in der Bestenliste platziert werden!",
                    "Platzieren fehlgeschlagen!", JOptionPane.ERROR_MESSAGE);
    } catch (Exception e1) {
        e1.printStackTrace();
        JOptionPane.showMessageDialog(null,
                "Dein Punktestand konnte nicht in der Bestenliste platziert werden!\nMglicherweise bist du nicht mit dem Internet verbunden.",
                "Platzieren fehlgeschlagen!", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:metodosnumericos.VentanaMetodoSecante.java

private void butCalcularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butCalcularActionPerformed
    if (txtIteraciones.getText().isEmpty() || txtTolerancia.getText().isEmpty() || txtX0.getText().isEmpty()
            || txtX1.getText().isEmpty()) {
        JOptionPane.showMessageDialog(null, "Verifique que los campos no esten vacios", "Mensaje",
                JOptionPane.INFORMATION_MESSAGE);
    } else {//www .  j  a  v a2 s .c o  m
        try {
            Graficador t = new Graficador();
            double tolerancia = Double.parseDouble(txtTolerancia.getText());
            int iteraciones = Integer.parseInt(txtIteraciones.getText());
            double x0 = Double.parseDouble(txtX0.getText());
            double x1 = Double.parseDouble(txtX1.getText());

            Metodos m = new Metodos();
            JOptionPane.showMessageDialog(null,
                    m.MetodoDeLaSecante(tolerancia, x0, x1, iteraciones, funcion, true), "Resultado",
                    JOptionPane.INFORMATION_MESSAGE);

            GeneradorTablas g = new GeneradorTablas();
            JTable tabla = g.tablaPuntoFijo(m.getSecanteXn(), m.getSecanteFxn(), m.getSecanteEa(),
                    m.getSecanteEr());

            double xs;
            //Si Xi < Xv
            if (x0 < m.getSecanteXn().get(m.getSecanteXn().size() - 1).doubleValue()) {
                xs = m.getSecanteXn().get(m.getSecanteXn().size() - 1).doubleValue() + 5;
            } else {
                xs = x0;
                x0 = m.getSecanteXn().get(m.getSecanteXn().size() - 1).doubleValue() - 5;
            }

            panelGrafica.removeAll();
            panelGrafica.add(t.series(funcion, x0, xs));
            panelGrafica.updateUI();

            panelTabla.removeAll();
            panelTabla.add(new JScrollPane(tabla));
            panelTabla.updateUI();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Verifique que los campos sean Numeros", "Mensaje",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    }

}

From source file:metodosnumericos.VentanaBusquedasIn.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    //boton calcular;
    if (jTextField1.getText().isEmpty() || jTextField2.getText().isEmpty() || jTextField3.getText().isEmpty()) {
        JOptionPane.showMessageDialog(null, "Verifique que los campos no esten vacios", "Mensaje",
                JOptionPane.INFORMATION_MESSAGE);

    } else {/*from w  ww . j  a  v  a2s .  c  o  m*/
        try {
            Graficador t = new Graficador();
            double delta = Double.parseDouble(jTextField2.getText());
            double iteraciones = Double.parseDouble(jTextField3.getText());
            double xi = Double.parseDouble(jTextField1.getText());
            double xs = xi + (delta * iteraciones);

            ChartPanel panel = t.series(funcion, xi, xs);
            panelGrafica.removeAll();
            panelGrafica.add(panel);
            panelGrafica.updateUI();

            Metodos m = new Metodos();
            JOptionPane.showMessageDialog(null,
                    m.Busqueda(xi, delta, Integer.parseInt(jTextField3.getText()), funcion), "Resultado",
                    JOptionPane.INFORMATION_MESSAGE);

            GeneradorTablas g = new GeneradorTablas();
            JTable tabla = g.tablaBusquedas(m.getBusquedax(), m.getBusquedaFx());

            panelTabla.removeAll();
            panelTabla.add(new JScrollPane(tabla));
            panelTabla.updateUI();

            VentanaUnaVariable vuv = new VentanaUnaVariable();

            System.out.println("Mire se encontro: " + funcion);
            Evaluador eva = new Evaluador();
            eva.Evaluador2(funcion, 2);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Verifique que los campos sean Numeros", "Mensaje",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    }

}

From source file:userInterface.CustomerWorkArea.CustomerWorkAreaJPanel.java

private void createChart() {
    DefaultCategoryDataset CarInspectionDataset = new DefaultCategoryDataset();

    ArrayList<CarInspection> carInspectionList = userAccount.getPerson().getCarInspectionHistory()
            .getCarInspectionHistory();/*  ww w.  j  a  v  a 2s  .c o  m*/
    /*At least 2 vital sign records needed to show chart */
    if (carInspectionList.isEmpty() || carInspectionList.size() == 1) {
        JOptionPane.showMessageDialog(this, " At least 2 car Inspection records needed to show chart!",
                "Warning", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    for (CarInspection carList : carInspectionList) {
        CarInspectionDataset.addValue(carList.getAlignment(), "RR", carList.getTimestamp());
        CarInspectionDataset.addValue(carList.getBattery(), "HR", carList.getTimestamp());
        CarInspectionDataset.addValue(carList.getBrakingSys(), "BP", carList.getTimestamp());
        CarInspectionDataset.addValue(carList.getOilCheck(), "WT", carList.getTimestamp());
    }

    JFreeChart carInspectionChart = ChartFactory.createBarChart3D("Car Inspection Chart", "Time Stamp",
            "Values", CarInspectionDataset, PlotOrientation.VERTICAL, true, false, false);
    carInspectionChart.setBackgroundPaint(Color.white);
    CategoryPlot carChartPlot = carInspectionChart.getCategoryPlot();
    carChartPlot.setBackgroundPaint(Color.lightGray);

    CategoryAxis vitalSignDomainAxis = carChartPlot.getDomainAxis();
    vitalSignDomainAxis
            .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    NumberAxis vitalSignRangeAxis = (NumberAxis) carChartPlot.getRangeAxis();
    vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartFrame chartFrame = new ChartFrame("Chart", carInspectionChart);
    chartFrame.setVisible(true);
    chartFrame.setSize(500, 500);

}

From source file:com.asprise.imaging.core.Imaging.java

public static void main(String[] args) {
    if (args == null) {
        args = new String[0];
    }/*  w w  w.  j  av a  2s.  co m*/

    // Try UI mode if possible
    try {
        if (!(args.length > 0 && "console".equalsIgnoreCase(args[args.length - 1]))
                && !java.awt.GraphicsEnvironment.isHeadless()) {
            Class<?> cls = Class.forName("com.asprise.imaging.scan.ui.workbench.demo.FrameScanDemo");
            Method meth = cls.getMethod("main", String[].class);
            String[] params = null; // init params accordingly
            meth.invoke(null, (Object) args); // static method doesn't have an instance
            return;
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }

    String copyright = "Copyright Asprise, " + Calendar.getInstance().get(Calendar.YEAR)
            + ". All Rights Reserved. Visit www.asprise.com";
    String version = "Library version: " + getLibraryVersion();

    try {
        JOptionPane.showMessageDialog(null, version, copyright,
                JOptionPane.OK_OPTION | JOptionPane.INFORMATION_MESSAGE);
    } catch (Throwable t) {
        // ignore exception
    }

    System.out.println(copyright);
    System.out.println(version);
    System.out.println(Utils.getEnvInfo(false));
}

From source file:metodosnumericos.VentanaRaicesM.java

private void butCalcularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butCalcularActionPerformed
    if (txtFddx.getText().isEmpty() || txtFdx.getText().isEmpty() || txtIteraciones.getText().isEmpty()
            || txtTolerancia.getText().isEmpty() || txtX0.getText().isEmpty()) {
        JOptionPane.showMessageDialog(null, "Verifique que los campos no esten vacios", "Mensaje",
                JOptionPane.INFORMATION_MESSAGE);
    } else {/*from   w w  w.ja  v  a  2 s  .  c  o m*/
        try {
            Graficador t = new Graficador();
            double tolerancia = Double.parseDouble(txtTolerancia.getText());
            int iteraciones = Integer.parseInt(txtIteraciones.getText());
            double xi = Double.parseDouble(txtX0.getText());
            String fdx = txtFdx.getText();
            String fddx = txtFddx.getText();

            Metodos m = new Metodos();
            JOptionPane.showMessageDialog(null,
                    m.RaicesMultiples(tolerancia, xi, iteraciones, funcion, fdx, fddx, true), "Resultado",
                    JOptionPane.INFORMATION_MESSAGE);

            GeneradorTablas g = new GeneradorTablas();

            JTable tabla = g.tablaRaicesM(m.getRaicesXn(), m.getRaicesFx(), m.getRaicesFdx(), m.getRaicesFddx(),
                    m.getRaicesEa(), m.getRaicesEr());
            double xs;
            //Si Xi < Xv
            if (xi < m.getRaicesXn().get(m.getRaicesXn().size() - 1).doubleValue()) {
                xs = m.getRaicesXn().get(m.getRaicesXn().size() - 1).doubleValue() + 5;
            } else {
                xs = xi;
                xi = m.getRaicesXn().get(m.getRaicesXn().size() - 1).doubleValue() - 5;
            }

            panelGrafica.removeAll();
            panelGrafica.add(t.series(funcion, xi, xs));
            panelGrafica.updateUI();

            panelTabla.removeAll();
            panelTabla.add(new JScrollPane(tabla));
            panelTabla.updateUI();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Verifique que los campos sean Numeros", "Mensaje",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    }

}

From source file:ConfigFiles.java

public ConfigFiles(Dimension screensize) {
    //         initializeFileBrowser();
    paths = new JPanel();
    paths.setBackground(Color.WHITE);
    //paths.setBorder(BorderFactory.createTitledBorder("Paths"));
    paths.setLayout(null);/*w w  w  . ja va2  s  .  c  om*/
    paths.setPreferredSize(new Dimension(930, 1144));
    paths.setSize(new Dimension(930, 1144));
    paths.setMinimumSize(new Dimension(930, 1144));
    paths.setMaximumSize(new Dimension(930, 1144));
    //paths.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    setLayout(null);
    ttcpath = new JTextField();
    addPanel("TestCase Source Path",
            "Master directory with the test cases that can" + " be run by the framework", ttcpath,
            RunnerRepository.TESTSUITEPATH, 10, true, null);
    tMasterXML = new JTextField();
    tUsers = new JTextField();

    addPanel("Projects Path", "Location of projects XML files", tUsers, RunnerRepository.REMOTEUSERSDIRECTORY,
            83, true, null);

    tSuites = new JTextField();
    addPanel("Predefined Suites Path", "Location of predefined suites", tSuites,
            RunnerRepository.PREDEFINEDSUITES, 156, true, null);

    testconfigpath = new JTextField();
    addPanel("Test Configuration Path", "Test Configuration path", testconfigpath,
            RunnerRepository.TESTCONFIGPATH, 303, true, null);

    tepid = new JTextField();
    addPanel("EP name File", "Location of the file that contains" + " the Ep name list", tepid,
            RunnerRepository.REMOTEEPIDDIR, 595, true, null);
    tlog = new JTextField();
    addPanel("Logs Path", "Location of the directory that stores the most recent log files."
            + " The files are re-used each Run.", tlog, RunnerRepository.LOGSPATH, 667, true, null);
    tsecondarylog = new JTextField();

    JPanel p = addPanel("Secondary Logs Path",
            "Location of the directory that archives copies of the most recent log files, with"
                    + " original file names appended with <.epoch time>",
            tsecondarylog, RunnerRepository.SECONDARYLOGSPATH, 930, true, null);
    logsenabled.setSelected(Boolean.parseBoolean(RunnerRepository.PATHENABLED));
    logsenabled.setBackground(Color.WHITE);
    p.add(logsenabled);

    JPanel p7 = new JPanel();
    p7.setBackground(Color.WHITE);
    TitledBorder border7 = BorderFactory.createTitledBorder("Log Files");
    border7.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border7.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p7.setBorder(border7);
    p7.setLayout(new BoxLayout(p7, BoxLayout.Y_AXIS));
    p7.setBounds(80, 740, 800, 190);
    paths.add(p7);
    JTextArea log2 = new JTextArea("All the log files that will be monitored");
    log2.setWrapStyleWord(true);
    log2.setLineWrap(true);
    log2.setEditable(false);
    log2.setCursor(null);
    log2.setOpaque(false);
    log2.setFocusable(false);
    log2.setBorder(null);
    log2.setFont(new Font("Arial", Font.PLAIN, 12));
    log2.setBackground(getBackground());
    log2.setMaximumSize(new Dimension(170, 25));
    log2.setPreferredSize(new Dimension(170, 25));
    JPanel p71 = new JPanel();
    p71.setBackground(Color.WHITE);
    p71.setLayout(new GridLayout());
    p71.setMaximumSize(new Dimension(700, 13));
    p71.setPreferredSize(new Dimension(700, 13));
    p71.add(log2);
    JPanel p72 = new JPanel();
    p72.setBackground(Color.WHITE);
    p72.setLayout(new BoxLayout(p72, BoxLayout.Y_AXIS));
    trunning = new JTextField();
    p72.add(addField(trunning, "Running: ", 0));
    tdebug = new JTextField();
    p72.add(addField(tdebug, "Debug: ", 1));
    tsummary = new JTextField();
    p72.add(addField(tsummary, "Summary: ", 2));
    tinfo = new JTextField();
    p72.add(addField(tinfo, "Info: ", 3));
    tcli = new JTextField();
    p72.add(addField(tcli, "Cli: ", 4));
    p7.add(p71);
    p7.add(p72);
    libpath = new JTextField();

    addPanel("Library path", "Secondary user library path", libpath, RunnerRepository.REMOTELIBRARY, 229, true,
            null);

    JPanel p8 = new JPanel();
    p8.setBackground(Color.WHITE);
    TitledBorder border8 = BorderFactory.createTitledBorder("File");
    border8.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border8.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p8.setBorder(border8);
    p8.setLayout(null);
    p8.setBounds(80, 1076, 800, 50);
    if (PermissionValidator.canChangeFWM()) {
        paths.add(p8);
    }
    JButton save = new JButton("Save");
    save.setToolTipText("Save and automatically load config");
    save.setBounds(490, 20, 70, 20);
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            saveXML(false, "fwmconfig");
            loadConfig("fwmconfig.xml");
        }
    });
    p8.add(save);
    //         if(!PermissionValidator.canChangeFWM()){
    //             save.setEnabled(false);
    //         }
    JButton saveas = new JButton("Save as");
    saveas.setBounds(570, 20, 90, 20);
    saveas.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            String filename = CustomDialog.showInputDialog(JOptionPane.QUESTION_MESSAGE,
                    JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "File Name", "Please enter file name");
            if (!filename.equals("NULL")) {
                saveXML(false, filename);
            }
        }
    });
    p8.add(saveas);

    final JButton loadXML = new JButton("Load Config");
    loadXML.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            try {
                String[] configs = RunnerRepository
                        .getRemoteFolderContent(RunnerRepository.USERHOME + "/twister/config/");
                JComboBox combo = new JComboBox(configs);
                int resp = (Integer) CustomDialog.showDialog(combo, JOptionPane.INFORMATION_MESSAGE,
                        JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "Config", null);
                final String config;
                if (resp == JOptionPane.OK_OPTION)
                    config = combo.getSelectedItem().toString();
                else
                    config = null;
                if (config != null) {
                    new Thread() {
                        public void run() {
                            setEnabledTabs(false);
                            JFrame progress = new JFrame();
                            progress.setAlwaysOnTop(true);
                            progress.setLocation((int) loadXML.getLocationOnScreen().getX(),
                                    (int) loadXML.getLocationOnScreen().getY());
                            progress.setUndecorated(true);
                            JProgressBar bar = new JProgressBar();
                            bar.setIndeterminate(true);
                            progress.add(bar);
                            progress.pack();
                            progress.setVisible(true);
                            loadConfig(config);
                            progress.dispose();
                            setEnabledTabs(true);
                        }
                    }.start();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    loadXML.setBounds(670, 20, 120, 20);
    p8.add(loadXML);
    //         if(!PermissionValidator.canChangeFWM()){
    //             loadXML.setEnabled(false);
    //         }

    tdbfile = new JTextField();
    addPanel("Database XML path", "File location for database configuration", tdbfile,
            RunnerRepository.REMOTEDATABASECONFIGPATH + RunnerRepository.REMOTEDATABASECONFIGFILE, 375, true,
            null);
    temailfile = new JTextField();
    //         emailpanel = (JPanel)
    addPanel("Email XML path", "File location for email configuration", temailfile,
            RunnerRepository.REMOTEEMAILCONFIGPATH + RunnerRepository.REMOTEEMAILCONFIGFILE, 448, true, null)
                    .getParent();
    //paths.remove(emailpanel);

    //         emailpanel.setBounds(360,440,350,100);
    //         RunnerRepository.window.mainpanel.p4.getEmails().add(emailpanel);

    tglobalsfile = new JTextField();
    addPanel("Globals XML file", "File location for globals parameters", tglobalsfile,
            RunnerRepository.GLOBALSREMOTEFILE, 521, true, null);

    tceport = new JTextField();
    addPanel("Central Engine Port", "Central Engine port", tceport, RunnerRepository.getCentralEnginePort(),
            1003, false, null);
    //         traPort = new JTextField();
    //         addPanel("Resource Allocator Port","Resource Allocator Port",
    //                 traPort,RunnerRepository.getResourceAllocatorPort(),808,false,null);                
    //         thttpPort = new JTextField();
    //         addPanel("HTTP Server Port","HTTP Server Port",thttpPort,
    //                 RunnerRepository.getHTTPServerPort(),740,false,null);

    //paths.add(loadXML);

    if (!PermissionValidator.canChangeFWM()) {
        ttcpath.setEnabled(false);
        tMasterXML.setEnabled(false);
        tUsers.setEnabled(false);
        tepid.setEnabled(false);
        tSuites.setEnabled(false);
        tlog.setEnabled(false);
        trunning.setEnabled(false);
        tdebug.setEnabled(false);
        tsummary.setEnabled(false);
        tinfo.setEnabled(false);
        tcli.setEnabled(false);
        tdbfile.setEnabled(false);
        temailfile.setEnabled(false);
        tceport.setEnabled(false);
        libpath.setEnabled(false);
        tsecondarylog.setEnabled(false);
        testconfigpath.setEnabled(false);
        tglobalsfile.setEnabled(false);
        logsenabled.setEnabled(false);
    }

}

From source file:be.agiv.security.demo.Main.java

private void secConvCancelToken() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    JPanel contentPanel = new JPanel(gridBagLayout);

    JLabel urlLabel = new JLabel("URL:");
    gridBagConstraints.gridx = 0;/*from  w  w  w . j a v a 2 s  . c  o m*/
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.ipadx = 5;
    gridBagLayout.setConstraints(urlLabel, gridBagConstraints);
    contentPanel.add(urlLabel);

    JTextField urlTextField = new JTextField(ClaimsAwareServiceFactory.SERVICE_SC_LOCATION, 60);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(urlTextField, gridBagConstraints);
    contentPanel.add(urlTextField);

    int result = JOptionPane.showConfirmDialog(this, contentPanel, "Secure Conversation Cancel Token",
            JOptionPane.OK_CANCEL_OPTION);
    if (result == JOptionPane.CANCEL_OPTION) {
        return;
    }

    String location = urlTextField.getText();

    SecureConversationClient secConvClient = new SecureConversationClient(location);
    try {
        secConvClient.cancelSecureConversationToken(this.secConvSecurityToken);
        this.secConvViewMenuItem.setEnabled(false);
        this.secConvCancelMenuItem.setEnabled(false);
        this.secConvSecurityToken = null;
        JOptionPane.showMessageDialog(this, "Secure conversation token cancelled.", "Secure Conversation",
                JOptionPane.INFORMATION_MESSAGE);
    } catch (Exception e) {
        showException(e);
    }
}