Example usage for javax.swing JOptionPane ERROR_MESSAGE

List of usage examples for javax.swing JOptionPane ERROR_MESSAGE

Introduction

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

Prototype

int ERROR_MESSAGE

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

Click Source Link

Document

Used for error messages.

Usage

From source file:com.sshtools.tunnel.PortForwardingPane.java

protected void addPortForward() {
    PortForwardEditorPane editor = new PortForwardEditorPane();
    int option = JOptionPane.showConfirmDialog(this, editor, "Add New Tunnel", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE);
    if (option != JOptionPane.CANCEL_OPTION && option != JOptionPane.CLOSED_OPTION) {
        try {/*from  w ww.ja va  2s.co  m*/
            ForwardingClient forwardingClient = client; //.getForwardingClient();
            String id = editor.getForwardName();
            if (id.equals("x11")) {
                throw new Exception("The id of x11 is reserved.");
            }
            int i = model.getRowCount();
            if (editor.isLocal()) {
                ForwardingConfiguration f = forwardingClient.addLocalForwarding(id, editor.getBindAddress(),
                        editor.getLocalPort(), editor.getHost(), editor.getRemotePort());
                forwardingClient.startLocalForwarding(id);
                active.addConfiguration(f);
            } else {
                ForwardingConfiguration f = forwardingClient.addRemoteForwarding(id, editor.getBindAddress(),
                        editor.getLocalPort(), editor.getHost(), editor.getRemotePort());
                forwardingClient.startRemoteForwarding(id);
                active.addConfiguration(f);
            }

            if (i < model.getRowCount()) {
                table.getSelectionModel().addSelectionInterval(i, i);
            }
        } catch (Exception e) {
            sessionPanel.setAvailableActions();
            JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        } finally {
            model.refresh();
            sessionPanel.setAvailableActions();
        }
    }
}

From source file:com.emr.schemas.TableRelationsForm.java

/**
 * Method to get all the columns in a table
 * @param tableName {@link String} Table name
 * @return {@link List} List of the table's columns
 *///from   www .  ja v a2  s .  c  o  m
private List getTableColumns(String tableName) {
    List columns = new ArrayList();
    try {
        DatabaseMetaData dbmd = emrConn.getMetaData();
        ResultSet rs = dbmd.getColumns(null, null, tableName, "%");
        while (rs.next()) {
            String colName = rs.getString(4);
            columns.add(colName);
        }
    } catch (SQLException e) {
        String stacktrace = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e);
        JOptionPane.showMessageDialog(this,
                "Could not fetch Tables for the KenyaEMR Database. Error Details: " + stacktrace,
                "Table Names Error", JOptionPane.ERROR_MESSAGE);
    }
    return columns;
}

From source file:com.raphfrk.craftproxyclient.gui.CraftProxyGUI.java

public void setDone() {
    SwingUtilities.invokeLater(new Runnable() {
        @Override//from   w ww . ja  v a2s.  c  om
        public void run() {
            if (connect.getText().equals("Stop") || connect.getText().equals("Stopping")) {
                connect.setText("Start");
                desiredSize.setEditable(true);
                serverName.setEditable(true);
                portNum.setEditable(true);
                setStatus("Server halted");
                localServerPortnum.setEditable(true);
            } else {
                JOptionPane.showMessageDialog(CraftProxyGUI.this,
                        "Error: server stopped notice received when it shouldn't have been running", "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });
}

From source file:edu.harvard.mcz.imagecapture.jobs.JobAllImageFilesScan.java

@Override
public void start() {
    startTime = new Date();
    Singleton.getSingletonInstance().getJobList().addJob((RunnableJob) this);
    runStatus = RunStatus.STATUS_RUNNING;
    File imagebase = null; // place to start the scan from, imagebase directory for SCAN_ALL
    startPoint = null;/*  w w  w .  j a  v  a  2 s . c  om*/
    // If it isn't null, retrieve the image base directory from properties, and test for read access.
    if (Singleton.getSingletonInstance().getProperties().getProperties()
            .getProperty(ImageCaptureProperties.KEY_IMAGEBASE) == null) {
        JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                "Can't start scan.  Don't know where images are stored.  Set imagbase property.", "Can't Scan.",
                JOptionPane.ERROR_MESSAGE);
    } else {
        imagebase = new File(Singleton.getSingletonInstance().getProperties().getProperties()
                .getProperty(ImageCaptureProperties.KEY_IMAGEBASE));
        if (imagebase != null) {
            if (imagebase.canRead()) {
                startPoint = imagebase;
            } else {
                // If it can't be read, null out imagebase
                imagebase = null;
            }
        }
        if (scan == SCAN_SPECIFIC && startPointSpecific != null && startPointSpecific.canRead()) {
            // A scan start point has been provided, don't launch a dialog.
            startPoint = startPointSpecific;
        }
        if (imagebase == null || scan == SCAN_SELECT) {
            // launch a file chooser dialog to select the directory to scan
            final JFileChooser fileChooser = new JFileChooser();
            fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            if (scan == SCAN_SELECT && startPointSpecific != null && startPointSpecific.canRead()) {
                fileChooser.setCurrentDirectory(startPointSpecific);
            } else {
                if (Singleton.getSingletonInstance().getProperties().getProperties()
                        .getProperty(ImageCaptureProperties.KEY_LASTPATH) != null) {
                    fileChooser.setCurrentDirectory(new File(Singleton.getSingletonInstance().getProperties()
                            .getProperties().getProperty(ImageCaptureProperties.KEY_LASTPATH)));
                }
            }
            int returnValue = fileChooser.showOpenDialog(Singleton.getSingletonInstance().getMainFrame());
            if (returnValue == JFileChooser.APPROVE_OPTION) {
                File file = fileChooser.getSelectedFile();
                log.debug("Selected base directory: " + file.getName() + ".");
                startPoint = file;
            } else {
                //TODO: handle error condition
                log.error("Directory selection cancelled by user.");
            }
            //TODO: Filechooser to pick path, then save (if SCAN_ALL) imagebase property. 
            //Perhaps.  Might be undesirable behavior.
            //Probably better to warn that imagebase is null;
        }

        // TODO: Check that startPoint is or is within imagebase.
        // Check that fileToCheck is within imagebase.
        if (!ImageCaptureProperties.isInPathBelowBase(startPoint)) {
            String base = Singleton.getSingletonInstance().getProperties().getProperties()
                    .getProperty(ImageCaptureProperties.KEY_IMAGEBASE);
            log.error("Tried to scan directory (" + startPoint.getPath() + ") outside of base image directory ("
                    + base + ")");
            String message = "Can't scan and database files outside of base image directory (" + base + ")";
            JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(), message,
                    "Can't Scan outside image base directory.", JOptionPane.YES_NO_OPTION);
        } else {

            // run in separate thread and allow cancellation and status reporting

            // walk through directory tree

            if (!startPoint.canRead()) {
                JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                        "Can't start scan.  Unable to read selected directory: " + startPoint.getPath(),
                        "Can't Scan.", JOptionPane.YES_NO_OPTION);
            } else {
                Singleton.getSingletonInstance().getMainFrame()
                        .setStatusMessage("Scanning " + startPoint.getPath());
                Counter counter = new Counter();
                // count files to scan
                countFiles(startPoint, counter);
                setPercentComplete(0);
                Singleton.getSingletonInstance().getMainFrame().notifyListener(runStatus, this);
                counter.incrementDirectories();
                // scan
                if (runStatus != RunStatus.STATUS_TERMINATED) {
                    checkFiles(startPoint, counter);
                }
                // report
                String report = "Scanned " + counter.getDirectories() + " directories.\n";
                report += "Created thumbnails in " + thumbnailCounter + " directories";
                if (thumbnailCounter == 0) {
                    report += " (May still be in progress)";
                }
                report += ".\n";
                if (startPointSpecific == null) {
                    report += "Starting with the base image directory (Preprocess All).\n";
                } else {
                    report += "Starting with " + startPoint.getName() + " (" + startPoint.getPath() + ")\n";
                    report += "First file: " + firstFile + " Last File: " + lastFile + "\n";
                }
                report += "Scanned  " + counter.getFilesSeen() + " files.\n";
                report += "Created  " + counter.getFilesDatabased() + " new image records.\n";
                if (counter.getFilesUpdated() > 0) {
                    report += "Updated  " + counter.getFilesUpdated() + " image records.\n";

                }
                report += "Created  " + counter.getSpecimens() + " new specimen records.\n";
                if (counter.getSpecimensUpdated() > 0) {
                    report += "Updated  " + counter.getSpecimensUpdated() + " specimen records.\n";

                }
                report += "Found " + counter.getFilesFailed() + " files with problems.\n";
                //report += counter.getErrors();
                Singleton.getSingletonInstance().getMainFrame().setStatusMessage("Preprocess scan complete");
                setPercentComplete(100);
                Singleton.getSingletonInstance().getMainFrame().notifyListener(runStatus, this);
                RunnableJobReportDialog errorReportDialog = new RunnableJobReportDialog(
                        Singleton.getSingletonInstance().getMainFrame(), report, counter.getErrors(),
                        "Preprocess Results");
                errorReportDialog.setVisible(true);
                //JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(), report, "Preprocess complete", JOptionPane.ERROR_MESSAGE);
            } // can read directory
        }

        SpecimenLifeCycle sls = new SpecimenLifeCycle();
        Singleton.getSingletonInstance().getMainFrame().setCount(sls.findSpecimenCount());
    } // Imagebase isn't null
    done();
}

From source file:TestOpenMailRelay.java

/** Construct a GUI and some I/O plumbing to get the output
 * of "TestOpenMailRelay" into the "results" textfield.
 *///from   w  w w  .j a  v  a 2 s.c om
public TestOpenMailRelayGUI() throws IOException {
    super("Tests for Open Mail Relays");
    PipedInputStream is;
    PipedOutputStream os;
    JPanel p;
    Container cp = getContentPane();
    cp.add(BorderLayout.NORTH, p = new JPanel());

    // The entry label and text field.
    p.add(new JLabel("Host:"));
    p.add(hostTextField = new JTextField(10));
    hostTextField.addActionListener(runner);

    p.add(goButton = new JButton("Try"));
    goButton.addActionListener(runner);

    JButton cb;
    p.add(cb = new JButton("Clear Log"));
    cb.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            results.setText("");
        }
    });
    JButton sb;
    p.add(sb = new JButton("Save Log"));
    sb.setEnabled(false);

    results = new JTextArea(20, 60);
    // Add the text area to the main part of the window (CENTER).
    // Wrap it in a JScrollPane to make it scroll automatically.
    cp.add(BorderLayout.CENTER, new JScrollPane(results));

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    pack(); // end of GUI portion

    // Create a pair of Piped Streams.
    is = new PipedInputStream();
    os = new PipedOutputStream(is);

    iis = new BufferedReader(new InputStreamReader(is, "ISO8859_1"));
    ps = new PrintStream(os);

    // Construct and start a Thread to copy data from "is" to "os".
    new Thread() {
        public void run() {
            try {
                String line;
                while ((line = iis.readLine()) != null) {
                    results.append(line);
                    results.append("\n");
                }
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(null, "*** Input or Output error ***\n" + ex, "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }.start();
}

From source file:ch.zhaw.iamp.rct.Controller.java

/**
 * Loads the mass-spring network graph from the masses file and the
 * connection map file, as configured in the {@link LoadGraphWindow}.
 *//*w w  w  .ja v  a2 s.c o  m*/
public void loadGraphFromFile() {
    String massesFilePath = loadGraphWindow.getMassesFilePath();
    String connectionMapFilePath = loadGraphWindow.getConnectionMapFilePath();

    try {
        String massesFile = FileUtils.readFileToString(new File(massesFilePath));
        String connectionMapFile = FileUtils.readFileToString(new File(connectionMapFilePath));
        NetworkGraph graph = GraphConverter.toNetworkGraph(massesFile, connectionMapFile);
        grammarWindow.getGrammarParser().setGraph(graph);
        grammarWindow.repaintGraphPanel();
    } catch (IOException ex) {
        Logger.getLogger(Controller.class.getName()).log(Level.WARNING,
                "Could not load the graph since the files could not be loaded: {0}", ex);
        JOptionPane.showMessageDialog(grammarWindow, "Could not load the given files: " + ex.getMessage(),
                "File Load Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:net.sf.jabref.importer.fetcher.IEEEXploreFetcher.java

@Override
public boolean processQuery(String query, ImportInspector dialog, OutputPrinter status) {
    //IEEE API seems to use .QT. as a marker for the quotes for exact phrase searching
    String terms = query.replaceAll("\"", "\\.QT\\.");

    shouldContinue = true;/*from   w w  w  .  ja va 2  s  . co m*/
    int parsed = 0;
    int pageNumber = 1;

    String postData = makeSearchPostRequestPayload(pageNumber, terms);

    try {
        //open the search URL
        URLDownload dl = new URLDownload(IEEEXploreFetcher.URL_SEARCH);

        //add request header
        dl.addParameters("Accept", "application/json");
        dl.addParameters("Content-Type", "application/json");

        // set post data
        dl.setPostData(postData);

        //retrieve the search results
        String page = dl.downloadToString(StandardCharsets.UTF_8);

        //the page can be blank if the search did not work (not sure the exact conditions that lead to this, but declaring it an invalid search for now)
        if (page.isEmpty()) {
            status.showMessage(Localization.lang("You have entered an invalid search '%0'.", query),
                    DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE);
            return false;
        }

        //parses the JSON data returned by the query
        //TODO: a faster way would be to parse the JSON tokens one at a time just to extract the article number, but this seems to be fast enough...
        JSONObject searchResultsJson = new JSONObject(page);
        int hits = searchResultsJson.getInt("totalRecords");

        //if no search results were found
        if (hits == 0) {
            status.showMessage(Localization.lang("No entries found for the search string '%0'", query),
                    DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE);
            return false;
        }

        //if max hits were exceeded, display the warning
        if (hits > IEEEXploreFetcher.MAX_FETCH) {
            status.showMessage(
                    Localization.lang("%0 entries found. To reduce server load, only %1 will be downloaded.",
                            String.valueOf(hits), String.valueOf(IEEEXploreFetcher.MAX_FETCH)),
                    DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE);
        }

        //fetch the raw Bibtex results from IEEEXplore
        String bibtexPage = new URLDownload(createBibtexQueryURL(searchResultsJson))
                .downloadToString(Globals.prefs.getDefaultEncoding());

        //preprocess the result (eg. convert HTML escaped characters to latex and do other formatting not performed by BibtexParser)
        bibtexPage = preprocessBibtexResultsPage(bibtexPage);

        //parse the page into Bibtex entries
        Collection<BibEntry> parsedBibtexCollection = BibtexParser.fromString(bibtexPage);
        if (parsedBibtexCollection == null) {
            status.showMessage(Localization.lang("Error while fetching from %0", getTitle()), DIALOG_TITLE,
                    JOptionPane.INFORMATION_MESSAGE);
            return false;
        }
        int nEntries = parsedBibtexCollection.size();
        Iterator<BibEntry> parsedBibtexCollectionIterator = parsedBibtexCollection.iterator();
        while (parsedBibtexCollectionIterator.hasNext() && shouldContinue) {
            dialog.addEntry(cleanup(parsedBibtexCollectionIterator.next()));
            dialog.setProgress(parsed, nEntries);
            parsed++;
        }

        return true;

    } catch (MalformedURLException e) {
        LOGGER.warn("Bad URL", e);
    } catch (ConnectException | UnknownHostException e) {
        status.showMessage(Localization.lang("Could not connect to %0", getTitle()), DIALOG_TITLE,
                JOptionPane.ERROR_MESSAGE);
    } catch (IOException | JSONException e) {
        status.showMessage(e.getMessage(), DIALOG_TITLE, JOptionPane.ERROR_MESSAGE);
        LOGGER.warn("Search IEEEXplore: " + e.getMessage(), e);
    }

    return false;
}

From source file:net.sf.housekeeper.swing.MainFrame.java

/**
 *  /*from   w w w . j  a v a 2  s  .  c om*/
 */
private void loadDomainData() {
    try {
        PersistenceController.instance().replaceDomainWithSaved();
    } catch (FileNotFoundException exception) {
        LOG.error("Could not load domain data", exception);
        final String error = LocalisationManager.INSTANCE.getText("gui.error");
        final String nodata = LocalisationManager.INSTANCE.getText("gui.mainFrame.nodata");
        JOptionPane.showMessageDialog(view, nodata, error, JOptionPane.ERROR_MESSAGE);
    } catch (Exception exception) {
        LOG.error("Could not load domain data", exception);
        final String error = LocalisationManager.INSTANCE.getText("gui.error");
        JOptionPane.showMessageDialog(view, exception.getLocalizedMessage(), error, JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.diversityarrays.kdxplore.KDXplore.java

public static void mainImpl(String[] args, Closure<KDXploreFrame> onCreateCallback,
        final Closure<UpdateCheckContext> updateChecker) {
    Locale defaultLocale = Locale.getDefault();
    System.out.println("Locale=" + defaultLocale); //$NON-NLS-1$

    // System.setProperty("apple.laf.useScreenMenuBar", "true");
    // //$NON-NLS-1$ //$NON-NLS-2$

    // Initialise the appFolder

    KdxplorePreferences prefs = KdxplorePreferences.getInstance();
    applyUIdefaultPreferences(prefs);/*from  ww w . j av a 2 s  . com*/

    String kdxploreName = KDXPLORE_APP_NAME;
    ApplicationFolder defaultAppFolder = ApplicationFolders.getApplicationFolder(kdxploreName);
    String[] newArgs = CommandArgs.parseRunModeOption(defaultAppFolder, args);

    String baseNameForDistrib = kdxploreName.toLowerCase();
    if (RunMode.DEMO == RunMode.getRunMode()) {
        kdxploreName = kdxploreName + "Demo"; //$NON-NLS-1$
    }
    final ApplicationFolder appFolder = ApplicationFolders.getApplicationFolder(kdxploreName);
    CommandArgs commandArgs = new CommandArgs(appFolder, KdxConstants.VERSION, KdxConstants.VERSION_CODE,
            newArgs);

    org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ClassPathExtender.class);

    if (commandArgs.baseDir == null) {
        File userDir = new File(System.getProperty("user.dir")); //$NON-NLS-1$

        File distribDir;
        if ("kdxos_main".equals(userDir.getName())) {
            // In Eclipse project this is where we store it
            distribDir = new File(userDir.getParentFile(), baseNameForDistrib);
        } else {
            distribDir = new File(userDir, baseNameForDistrib);
        }

        System.out.println("userDir=" + userDir); //$NON-NLS-1$
        System.out.println("distribDir=" + distribDir); //$NON-NLS-1$

        commandArgs.baseDir = distribDir.isDirectory() ? distribDir : userDir;
    }

    if (!commandArgs.baseDir.isDirectory()) {
        GuiUtil.errorMessage(null, "baseDir is not a directory: " + commandArgs.baseDir); //$NON-NLS-1$
        System.exit(1);
    }

    File libDir = new File(commandArgs.baseDir, "lib"); //$NON-NLS-1$
    File[] libFiles = libDir.listFiles();
    if (libFiles == null) {
        MsgBox.error(null, Msg.MSG_APP_START_DIRECTORY(kdxploreName, commandArgs.baseDir),
                Msg.ERRTITLE_MISSING_LIBRARY_FILES() + ": " + libDir.getPath());
        System.exit(1);
    } else if (libFiles.length < REQD_LIB_COUNT) {
        MsgBox.error(null, Msg.MSG_APP_START_DIRECTORY(kdxploreName, commandArgs.baseDir),
                Msg.ERRTITLE_MISSING_LIBRARY_FILES() + ": " + libFiles.length);
        System.exit(1);
    }

    // = = = = = = = = = = = = = = = = = = =
    // = = = = = = = = = = = = = = = = = = =
    // = = = = = = = CLASSPATH = = = = = = =
    ClassPathExtender.VERBOSE = !commandArgs.quiet; // RunMode.getRunMode().isDeveloper();
    String libs_sb = "lib,plugins,kdxlibs,../runlibs"; //$NON-NLS-1$

    boolean[] seenPdfbox = new boolean[1];
    Consumer<File> jarChecker = new Consumer<File>() {
        @Override
        public void accept(File f) {
            if (f.getName().startsWith("pdfbox")) {
                seenPdfbox[0] = true;
            }
        }
    };
    ClassPathExtender.appendToClassPath(commandArgs.baseDir, libs_sb, jarChecker, log);
    if (seenPdfbox[0]) {
        System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider");
    }

    // = = = = = = = = = = = = = = = = = = =
    // = = = = = = = = = = = = = = = = = = =
    // = = = = = = = = = = = = = = = = = = =

    doStaticInitChecks(commandArgs.quiet);
    if (commandArgs.runInitChecks) {
        System.out.println("Init checks OK"); //$NON-NLS-1$
        System.exit(0);
    }

    establishLogger(appFolder);

    @SuppressWarnings("unused")
    String configName = commandArgs.establishKdxConfig();

    Long versionSubinfo = null;
    if (commandArgs.errmsg == null) {
        if (!KdxploreConfig.getInstance().isEternal()) {
            commandArgs.expiryChecks(KdxConstants.VERSION);
            versionSubinfo = KdxConstants.getVersionSubinfo();
            if (versionSubinfo == Long.MAX_VALUE) {
                versionSubinfo = null;
            }
        }
    }

    String baseTitle = appFolder.getApplicationName() + " v" + KdxConstants.VERSION; //$NON-NLS-1$

    String expiresIn = ""; //$NON-NLS-1$
    if (versionSubinfo != null) {
        if ((0 < versionSubinfo && versionSubinfo < 14) || RunMode.getRunMode().isDeveloper()) {
            expiresIn = " " + Msg.KDX_EXPIRES_IN_N_DAYS(versionSubinfo.intValue()); //$NON-NLS-1$
        }
    }
    if (commandArgs.errmsg != null) {
        JOptionPane.showMessageDialog(null, commandArgs.errmsg, baseTitle + expiresIn,
                JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }

    final String kdxploreTitle = buildKdxploreTitle(baseTitle, expiresIn,
            commandArgs.kdxConfigService.getConfigName());

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            // TODO allow user to change "base font size"
            String uiMultiplier = null;
            try {
                String propertyName = CommandArgs.UI_MULTIPLIER_PROPERTY_NAME;
                uiMultiplier = System.getProperty(propertyName);
                if (uiMultiplier != null) {
                    try {
                        float multiplier = Float.parseFloat(uiMultiplier);
                        setUIfontSize(multiplier);
                    } catch (NumberFormatException e) {
                        System.err.println(String.format("?invalid value for %s: %s", //$NON-NLS-1$
                                propertyName, uiMultiplier));
                    }
                }
            } catch (SecurityException e) {
                System.err.println(String.format("Ignoring: %s %s", //$NON-NLS-1$
                        e.getClass().getSimpleName(), e.getMessage()));
            }

            GuiUtil.initLookAndFeel();

            try {
                KDXploreFrame frame = new KDXploreFrame(appFolder, kdxploreTitle, KdxConstants.VERSION_CODE,
                        KdxConstants.VERSION, updateChecker);
                frame.setVisible(true);
                if (onCreateCallback != null) {
                    onCreateCallback.execute(frame);
                }
            } catch (IOException e) {
                MsgBox.error(null, e, Msg.ERRTITLE_UNABLE_TO_START_KDXPLORE(KDXPLORE_APP_NAME));
            }

        }
    });
}

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

/**
 * Create the dialog.// w  w w .  j a v a2  s.  c  o  m
 */
public AqiSettingDialog(Frame owner, final AbstractAqiParser aqiParser) {
    super(owner);
    this.aqiParser = aqiParser;
    setTitle("\u8BBE\u7F6E");
    setResizable(false);
    setBounds(100, 100, 450, 135);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    GridBagLayout gbl_contentPanel = new GridBagLayout();
    gbl_contentPanel.columnWidths = new int[] { 33, 48, 66, 41, 48, 66, 0, 0 };
    gbl_contentPanel.rowHeights = new int[] { 21, 0, 0 };
    gbl_contentPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    contentPanel.setLayout(gbl_contentPanel);
    {
        JLabel lblRetryTimes = new JLabel("\u91CD\u8BD5\u6B21\u6570\uFF1A");
        GridBagConstraints gbc_lblRetryTimes = new GridBagConstraints();
        gbc_lblRetryTimes.anchor = GridBagConstraints.WEST;
        gbc_lblRetryTimes.insets = new Insets(0, 0, 5, 5);
        gbc_lblRetryTimes.gridx = 1;
        gbc_lblRetryTimes.gridy = 0;
        contentPanel.add(lblRetryTimes, gbc_lblRetryTimes);
    }
    {
        tfRetryTimes = new JTextField();
        tfRetryTimes.setPreferredSize(new Dimension(6, 29));
        tfRetryTimes.setMinimumSize(new Dimension(60, 29));
        GridBagConstraints gbc_tfRetryTimes = new GridBagConstraints();
        gbc_tfRetryTimes.anchor = GridBagConstraints.NORTHWEST;
        gbc_tfRetryTimes.insets = new Insets(0, 0, 5, 5);
        gbc_tfRetryTimes.gridx = 2;
        gbc_tfRetryTimes.gridy = 0;
        contentPanel.add(tfRetryTimes, gbc_tfRetryTimes);
        tfRetryTimes.setColumns(10);
    }
    {
        JLabel lblRetryGap = new JLabel("\u91CD\u8BD5\u95F4\u9694\uFF1A");
        GridBagConstraints gbc_lblRetryGap = new GridBagConstraints();
        gbc_lblRetryGap.anchor = GridBagConstraints.WEST;
        gbc_lblRetryGap.insets = new Insets(0, 0, 5, 5);
        gbc_lblRetryGap.gridx = 4;
        gbc_lblRetryGap.gridy = 0;
        contentPanel.add(lblRetryGap, gbc_lblRetryGap);
    }
    {
        tfRetryGap = new JTextField();
        tfRetryGap.setMinimumSize(new Dimension(60, 29));
        tfRetryGap.setPreferredSize(new Dimension(60, 29));
        GridBagConstraints gbc_tfRetryGap = new GridBagConstraints();
        gbc_tfRetryGap.insets = new Insets(0, 0, 5, 5);
        gbc_tfRetryGap.anchor = GridBagConstraints.NORTHWEST;
        gbc_tfRetryGap.gridx = 5;
        gbc_tfRetryGap.gridy = 0;
        contentPanel.add(tfRetryGap, gbc_tfRetryGap);
        tfRetryGap.setColumns(10);
    }
    {
        JLabel label = new JLabel("\u5206\u949F");
        GridBagConstraints gbc_label = new GridBagConstraints();
        gbc_label.insets = new Insets(0, 0, 5, 0);
        gbc_label.gridx = 6;
        gbc_label.gridy = 0;
        contentPanel.add(label, gbc_label);
    }
    {
        JLabel lblExportPath = new JLabel("\u8F93\u51FA\u8DEF\u5F84\uFF1A");
        GridBagConstraints gbc_lblExportPath = new GridBagConstraints();
        gbc_lblExportPath.anchor = GridBagConstraints.EAST;
        gbc_lblExportPath.insets = new Insets(0, 0, 0, 5);
        gbc_lblExportPath.gridx = 1;
        gbc_lblExportPath.gridy = 1;
        contentPanel.add(lblExportPath, gbc_lblExportPath);
    }
    {
        tfExportPath = new JTextField();
        tfExportPath.setEditable(false);
        tfExportPath.setPreferredSize(new Dimension(180, 29));
        tfExportPath.setMinimumSize(new Dimension(180, 29));
        GridBagConstraints gbc_tfExportPath = new GridBagConstraints();
        gbc_tfExportPath.gridwidth = 4;
        gbc_tfExportPath.insets = new Insets(0, 0, 0, 5);
        gbc_tfExportPath.fill = GridBagConstraints.HORIZONTAL;
        gbc_tfExportPath.gridx = 2;
        gbc_tfExportPath.gridy = 1;
        contentPanel.add(tfExportPath, gbc_tfExportPath);
        tfExportPath.setColumns(10);
    }
    {
        JButton button = new JButton("...");
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                fDialog = new JFileChooser(); // 
                fDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                int result = fDialog.showOpenDialog(contentPanel);
                if (result == JFileChooser.APPROVE_OPTION) {
                    tfExportPath.setText(fDialog.getSelectedFile().getAbsolutePath());
                }
            }
        });
        GridBagConstraints gbc_button = new GridBagConstraints();
        gbc_button.gridx = 6;
        gbc_button.gridy = 1;
        contentPanel.add(button, gbc_button);
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton okButton = new JButton("\u786E\u5B9A");
            okButton.setName("settingOk");
            okButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {

                    String retryTimes = tfRetryTimes.getText();
                    if (StringUtils.isEmpty(retryTimes) || !isNumeric(retryTimes)) {
                        JOptionPane.showMessageDialog(contentPanel, "", "",
                                JOptionPane.ERROR_MESSAGE);
                        return;
                    }

                    String retryGap = tfRetryGap.getText();
                    if (StringUtils.isEmpty(retryGap) || !isNumeric(retryGap)) {
                        JOptionPane.showMessageDialog(contentPanel, "", "",
                                JOptionPane.ERROR_MESSAGE);
                        return;
                    }

                    String exportPath = tfExportPath.getText();
                    if (StringUtils.isEmpty(exportPath)) {
                        JOptionPane.showMessageDialog(contentPanel, "", "",
                                JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    File testFile = new File(exportPath);
                    if (!testFile.exists()) {
                        JOptionPane.showMessageDialog(contentPanel, "", "",
                                JOptionPane.ERROR_MESSAGE);
                        return;
                    }

                    props.put("query.retryTimes", retryTimes);
                    props.put("query.retryGap", retryGap);
                    props.put("result.path", exportPath);

                    try {
                        props.store(new FileOutputStream(propertiesResource.getFile()), "");
                        aqiParser.setRetryTimes(Integer.parseInt(retryTimes));
                        aqiParser.setRetryGap(Integer.parseInt(retryGap));
                        aqiParser.setFilePath(exportPath);
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    } finally {
                        dispose();
                    }
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("\u53D6\u6D88");
            cancelButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    dispose();
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
}