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

@Override
protected void listBtnPressed() {
    // List button will only be enabled if a single taxon is selected.
    if (_list.getSelectedValue() != null) {

        List<Item> taxa = new ArrayList<Item>();
        String selectedKeyword = (String) _list.getSelectedValue();

        // do nothing if the "specimen" keyword is selected - this is not a
        // real taxon keyword.
        if (selectedKeyword.equals(IntkeyContext.SPECIMEN_KEYWORD)) {
            return;
        }//www  . jav a  2  s. co  m

        taxa.addAll(_context.getTaxaForKeyword(selectedKeyword));

        if (_selectFromIncluded) {
            taxa.retainAll(_includedTaxa);
        }

        if (taxa.isEmpty()) {
            JOptionPane.showMessageDialog(this, allTaxaInSelectedSetExcludedCaption, title,
                    JOptionPane.ERROR_MESSAGE);
        } else {
            TaxonSelectionDialog taxonDlg = new TaxonSelectionDialog(this, taxa, _directiveName,
                    selectedKeyword, _context.displayNumbering(), false, _context, _includeSpecimenAsOption,
                    _specimenSelectedReturnValue);
            taxonDlg.setVisible(true);

            List<Item> taxaSelectedInDlg = taxonDlg.getSelectedTaxa();
            if (taxaSelectedInDlg != null && taxaSelectedInDlg.size() > 0) {
                if (_selectedTaxa == null) {
                    _selectedTaxa = new ArrayList<Item>();
                }
                _selectedTaxa.clear();
                _selectedTaxa.addAll(taxaSelectedInDlg);
                this.setVisible(false);
            }
        }
    }
}

From source file:edu.wpi.cs.wpisuitetng.janeway.gui.login.LoginController.java

/**
 * Method that is called by {@link LoginRequestObserver} if the login
 * request was unsuccessful.// w w  w.j ava 2  s.  c  o m
 * @param response A string representing the error that occurred.
 */
public void loginFailed(String error) {
    JOptionPane.showMessageDialog(view, "Unable to login: " + error, "Login Error", JOptionPane.ERROR_MESSAGE);
}

From source file:de.juwimm.cms.Main.java

public Main(String[] argv) {
    // Bugfix [CH], use the "old" Java 5 RepaintManager (no-arg constructor creates one) for current thread group
    // instead of setting the system property "swing.bufferPerWindow" to false (does not work with JavaWebStart)
    PerformanceUtils.start();//from  w w w  . ja v  a2  s. co m
    RepaintManager.setCurrentManager(new RepaintManager());

    System.setProperty("swing.aatext", "true");
    try {
        InputStream in = this.getClass().getResourceAsStream("/pom.xml");
        String pom = IOUtils.toString(in);
        Document doc = XercesHelper.string2Dom(pom);

        String version = XercesHelper.getNodeValue(doc, "/project/version");
        System.setProperty("tizzit.version", version);

        Constants.CMS_VERSION = "V " + version;

        logSys("Starting Tizzit Version " + Constants.CMS_VERSION);
    } catch (Exception e) {
    }
    //SplashShell splash = new SplashShell();
    FrmVersion splash = new FrmVersion();
    int screenHeight = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
    int screenWidth = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
    int frameHeight = 300;
    int frameWidth = 450;
    splash.setLocation((screenWidth / 2) - (frameWidth / 2), (screenHeight / 2) - (frameHeight / 2));
    splash.setIconImage(new ImageIcon(getClass().getResource("/images/cms_16x16.gif")).getImage());
    splash.setSize(frameWidth, frameHeight);
    splash.setVisible(true);

    String host = "";
    if (argv.length >= 2 && argv[0].equals("URL_HOST")) {
        try {
            URL url = new URL(argv[1]);
            Constants.URL_HOST = url.toString();
            host = url.getHost();
            Constants.SERVER_SSL = url.getProtocol().equalsIgnoreCase("https");
            if (Constants.SERVER_SSL) {
                JOptionPane.showMessageDialog(null,
                        "Fehler beim Erstellen der SSL Verbindung!\nBitte wenden Sie sich an den Tizzit Support.",
                        "Tizzit", JOptionPane.ERROR_MESSAGE);
                System.exit(-1);
            }
            Constants.SERVER_PORT = (url.getPort() == -1) ? ((Constants.SERVER_SSL) ? 443 : 80) : url.getPort();
        } catch (Exception exe) {
            log.error(exe);
        }
    } else if (argv.length == 1) {
        host = argv[0];
    } else {
        return;
    }
    if ("".equalsIgnoreCase(host)) {
        return;
    }

    logSys("CONNECTING HOST " + host + " " + argv[1] + " with SSL " + Constants.SERVER_SSL);
    Constants.SERVER_HOST = host;
    Constants.SVG_CACHE = Constants.DB_PATH + "svgcache_" + Constants.SERVER_HOST
            + System.getProperty("file.separator");
    UIConstants.setMainFrame(this);

    logSys("Setting SAX/DOM XML Parser to Apache Xerces");
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
            "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
    System.setProperty("javax.xml.parsers.DocumentBuilder", "org.apache.xerces.jaxp.DocumentBuilderImpl"); // needed?
    System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
    System.setProperty("javax.xml.parsers.SAXParser", "org.apache.xerces.jaxp.SAXParserImpl"); //needed?
    System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser"); //needed?
    initLog4J(host, argv);
    PerformanceUtils.mark("Initial stage");
    String testUrl = ((Constants.SERVER_SSL) ? "https://" : "http://") + Constants.SERVER_HOST + ":"
            + Constants.SERVER_PORT + "/admin/juwimm-cms-client.jnlp";
    try {
        URI desturi = new URI(testUrl);
        ProxyHelper helper = new ProxyHelper();
        helper.init(desturi, false);

    } catch (IllegalArgumentException ex) {
        logSys("could not initialize the proxy settings for host " + host + ": " + ex);
    } catch (URISyntaxException ex) {
        logSys("could not initialize the proxy settings because URI from host " + host + ": " + ex);
        // log.error("could not initialize the proxy settings because URI from host " + host + " : ", ex);
    }
    PerformanceUtils.mark("Initialising proxy server");
    try {
        UIManager.getLookAndFeelDefaults().put("ClassLoader", getClass().getClassLoader());
        LookAndFeel.switchTo(LookAndFeel.determineLookAndFeel());
    } catch (Exception exe) {
        log.error("Can't switch to Default LookAndFeel");
    }
    PerformanceUtils.mark("Initialising look and feel");
    splash.setStatusInfo("Invoking Bean Framework...");
    Application.initializeContext();
    PerformanceUtils.mark("Initialising spring context");
    splash.setStatusInfo("Getting Locale Settings...");

    try {
        Constants.rb = ResourceBundle.getBundle("CMS", Constants.CMS_LOCALE);
    } catch (Exception ex) {
        log.warn("Could not find ResourceBundle for language: " + Constants.CMS_LOCALE + " - loading default");
        Constants.rb = ResourceBundle.getBundle("CMS", Constants.CMS_LOCALE);
    }
    PerformanceUtils.mark("Loading resource bundle");
    splash.setStatusInfo(Constants.rb.getString("splash.checkingSSL"));
    HttpClientWrapper httpClientWrapper = HttpClientWrapper.getInstance();

    try {
        httpClientWrapper.testAndConfigureConnection(testUrl);
    } catch (HttpException exe) {
        JOptionPane.showMessageDialog(null, exe.getMessage(), Constants.rb.getString("dialog.title"),
                JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    }
    PerformanceUtils.mark("Initialising client wrapper");
    splash.setStatusInfo(Constants.rb.getString("splash.configBrowserSettings"));
    Browser.init(); // only needs to be called once.
    splash.setStatusInfo(Constants.rb.getString("splash.gettingTemplates"));
    comm = ((Communication) getBean(Beans.COMMUNICATION));
    splash.setStatusInfo(Constants.rb.getString("splash.locadingLocalCachingDatabase"));
    comm.getDbHelper(); // check if there is already a programm running
    ActionHub.addActionListener(this);
    rb = Constants.rb;
    PerformanceUtils.mark("Initialising dbHelper");
    splash.setStatusInfo(Constants.rb.getString("splash.initUI"));
    try {
        this.getContentPane().setLayout(new BorderLayout());
        panLogin = new PanLogin();
        setCenterPanel(panLogin);
        Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_LOGIN;
        screenHeight = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
        screenWidth = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
        frameWidth = Constants.CMS_SCREEN_WIDTH;
        frameHeight = Constants.CMS_SCREEN_HEIGHT;
        this.setSize(frameWidth, frameHeight);
        this.setLocationRelativeTo(null);
        this.setIconImage(UIConstants.CMS.getImage());
        this.setTitle(rb.getString("dialog.title") + " " + Constants.CMS_VERSION);
        this.addWindowListener(new MyWindowListener());
        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

        if (screenHeight <= frameHeight && screenWidth <= frameWidth) {
            this.setExtendedState(MAXIMIZED_BOTH);
        }

        this.setVisible(true);
        // splash.disposeMe(true);
        splash.dispose();

        // unimportant stuff
        UIConstants.loadImages();

    } catch (Exception exe) {
        log.error("Tizzit will exit", exe);
        JOptionPane.showMessageDialog(this, exe.getMessage() + "\nCMS will exit.", "CMS",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        //splash.disposeMe();
        splash.dispose();
    }
    PerformanceUtils.mark("Initialising main window");
}

From source file:org.esa.beam.visat.toolviews.stat.ChartPagePanel.java

private JPanel createChartBottomPanel(final ChartPanel chartPanel) {

    final AbstractButton zoomAllButton = ToolButtonFactory.createButton(
            UIUtils.loadImageIcon("/com/bc/ceres/swing/actions/icons_22x22/view-fullscreen.png"), false);
    zoomAllButton.setToolTipText("Zoom all.");
    zoomAllButton.setName("zoomAllButton.");
    zoomAllButton.addActionListener(new ActionListener() {
        @Override//from  w  w  w  . ja v  a2  s . c o  m
        public void actionPerformed(ActionEvent e) {
            chartPanel.restoreAutoBounds();
            chartPanel.repaint();
        }
    });

    final AbstractButton propertiesButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Edit24.gif"), false);
    propertiesButton.setToolTipText("Edit properties.");
    propertiesButton.setName("propertiesButton.");
    propertiesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            chartPanel.doEditChartProperties();
        }
    });

    final AbstractButton saveButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false);
    saveButton.setToolTipText("Save chart as image.");
    saveButton.setName("saveButton.");
    saveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                chartPanel.doSaveAs();
            } catch (IOException e1) {
                JOptionPane.showMessageDialog(chartPanel, "Could not save chart:\n" + e1.getMessage(), "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    final AbstractButton printButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Print24.gif"), false);
    printButton.setToolTipText("Print chart.");
    printButton.setName("printButton.");
    printButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            chartPanel.createChartPrintJob();
        }
    });

    final TableLayout tableLayout = new TableLayout(6);
    tableLayout.setColumnFill(4, TableLayout.Fill.HORIZONTAL);
    tableLayout.setColumnWeightX(4, 1.0);
    JPanel buttonPanel = new JPanel(tableLayout);
    tableLayout.setRowPadding(0, new Insets(0, 4, 0, 0));
    buttonPanel.add(zoomAllButton);
    tableLayout.setRowPadding(0, new Insets(0, 0, 0, 0));
    buttonPanel.add(propertiesButton);
    buttonPanel.add(saveButton);
    buttonPanel.add(printButton);
    buttonPanel.add(new JPanel());
    buttonPanel.add(getHelpButton());

    return buttonPanel;
}

From source file:com.endlessloopsoftware.ego.client.graph.GraphRenderer.java

/**
 * Changes the size of the layout (canvas size) then redraws the graph 
 * to fit the nodes to the new layout size
 * //  w  w w  .  j a  v  a2s . c om
 * @param int x -- width
 * @param int y -- height
 */
@SuppressWarnings("unchecked")
public void changeLayoutSize(int x, int y) {
    try {
        Dimension dim = visualizationViewer.getGraphLayout().getSize();
        Layout layout = visualizationViewer.getGraphLayout();

        if (dim.width + x < 5 || dim.height + y < 5) {
            JOptionPane.showMessageDialog(null, new String("Layout Size Out of Bounds"), "Error",
                    JOptionPane.ERROR_MESSAGE);
            logger.info("Less than 5");
        } else {
            Dimension d = new Dimension(dim.width + x, dim.height + y);
            //visualizationViewer.stop();
            visualizationViewer.getModel().setGraphLayout(layout, d);
            //visualizationViewer.restart();
        }
    } catch (Exception ex) {
        logger.error(ex.toString());
    }

}

From source file:com.firmansyah.imam.sewa.kendaraan.FormRegister.java

private void btnRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegisterActionPerformed
    String nama = inputNama.getText();
    String nama_filter = nama.replaceAll(" ", "%20");

    String username = inputUsername.getText();
    String password = inputPassword.getText();
    String password_hash = DigestUtils.md5Hex(password);

    System.out.println("Nama : " + nama);
    System.out.println("Username : " + username);
    System.out.println("Password : " + password);

    if (nama.isEmpty() || username.isEmpty() || password.isEmpty()) {

        JOptionPane.showMessageDialog(this, "Data Tidak Boleh Kosong", "Informasi", JOptionPane.ERROR_MESSAGE);

    } else if (username.contains(" ")) {

        JOptionPane.showMessageDialog(this, "Username Tidak Boleh Menggunakan Spasi", "Informasi",
                JOptionPane.ERROR_MESSAGE);

    } else {/*  w  w  w  .  jav a2  s  .c o m*/

        String url = Path.serverURL + "/user/create/" + username + "/" + password_hash + "/" + nama_filter;

        getDataURL dataurl = new getDataURL();

        try {

            String data = dataurl.getData(url);
            System.out.println(data);

            if (data.equals("1")) {

                JOptionPane.showMessageDialog(this, "Registrasi Berhasil,\nSelamat Begabung " + nama,
                        "Informasi", JOptionPane.INFORMATION_MESSAGE);

                // memanggil form login
                FormLogin callForm = new FormLogin();
                callForm.setLocationRelativeTo(null);
                callForm.setVisible(true);

                this.dispose();

            } else {

                JOptionPane.showMessageDialog(this, "Registrasi Gagal\nUsername Sudah digunakan", "Informasi",
                        JOptionPane.ERROR_MESSAGE);

            }

        } catch (IOException ex) {
            Logger.getLogger(FormRegister.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.dragoniade.deviantart.deviation.SearchStream.java

public List<Deviation> search(ProgressDialog progress, Collection collection) {
    if (user == null) {
        throw new IllegalStateException("You must set the user before searching.");
    }//  w w w .j  a  v  a 2 s.co  m
    if (search == null) {
        throw new IllegalStateException("You must set the search type before searching.");
    }
    String searchQuery = search.getSearch().replace("%username%", user);
    String queryString = "http://www.deviantart.com/global/difi.php?c=Stream;thumbs;" + searchQuery + ","
            + offset + "," + OFFSET + "&t=xml";
    GetMethod method = new GetMethod(queryString);
    List<Deviation> results = new ArrayList<Deviation>(OFFSET);
    try {
        int sc = -1;
        do {
            sc = client.executeMethod(method);
            if (sc != 200) {
                int res = DialogHelper.showConfirmDialog(owner,
                        "An error has occured when contacting deviantART : error " + sc + ". Try again?",
                        "Continue?", JOptionPane.YES_NO_OPTION);
                if (res == JOptionPane.NO_OPTION) {
                    return null;
                }
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                }
            }
        } while (sc != 200);

        XmlToolkit toolkit = XmlToolkit.getInstance();

        StringBuilder stringBuilder = new StringBuilder();
        InputStream inputStream = method.getResponseBodyAsStream();
        int b;
        boolean isOpening = false;
        while ((b = inputStream.read()) > -1) {
            if (b > 127) {
                isOpening = false;
                continue;
            }
            char c = (char) b;
            if (isOpening && Character.isDigit(c)) {
                stringBuilder.append('_');
            }
            if (isOpening && c == '/') {
                stringBuilder.append(c);
                continue;
            }
            isOpening = (c == '<');
            stringBuilder.append(c);
        }

        Element responses = toolkit.parseDocument(stringBuilder.toString());
        method.releaseConnection();

        total = toolkit.getNodeAsInt(responses, "response/calls/response/content/total");
        List<?> deviations = toolkit.getMultipleNodes(responses, "response/calls/response/content/deviations");
        if (total == 0) {
            return results;
        }
        for (Object obj : deviations) {
            Element deviation = (Element) obj;

            Deviation da = new Deviation();
            da.setId(toolkit.getNodeAsLong(deviation, "id"));
            da.setArtist(toolkit.getNodeAsString(deviation, "artist"));
            da.setCategory(toolkit.getNodeAsString(deviation, "category"));
            da.setTitle(toolkit.getNodeAsString(deviation, "title"));
            da.setUrl(toolkit.getNodeAsString(deviation, "url"));
            da.setTimestamp(new Date(toolkit.getNodeAsLong(deviation, "ts") * 1000));
            da.setMature("1".equals(toolkit.getNodeAsString(deviation, "is_mature")));
            da.setCollection(collection);

            String filenameStr = toolkit.getNodeAsString(deviation, "filename");
            String imageUrl = toolkit.getNodeAsString(deviation, "image/url");

            String primaryFilename = Deviation.extractFilename(filenameStr);
            da.setDocumentDownloadUrl(DOWNLOAD_URL + da.getId() + "/");
            da.setDocumentFilename(primaryFilename);

            if (imageUrl != null) {
                String secondaryFilename = Deviation.extractFilename(imageUrl);
                da.setImageDownloadUrl(imageUrl);
                da.setImageFilename(secondaryFilename);
                da.setResolution(toolkit.getNodeAsString(deviation, "image/width") + "x"
                        + toolkit.getNodeAsString(deviation, "image/height"));
            }

            results.add(da);
        }
        offset = offset + deviations.size();
        return results;
    } catch (HttpException e) {
        DialogHelper.showMessageDialog(owner, "Error contacting deviantART : " + e.getMessage() + ".", "Error",
                JOptionPane.ERROR_MESSAGE);
        return null;
    } catch (IOException e) {
        DialogHelper.showMessageDialog(owner, "Error contacting deviantART : " + e.getMessage() + ".", "Error",
                JOptionPane.ERROR_MESSAGE);
        return null;
    }
}

From source file:EditorPaneExample10.java

public EditorPaneExample10() {
    super("JEditorPane Example 10");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;//  ww w.  j  a va2s .c  om
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            try {
                // Check if the new page and the old
                // page are the same.
                URL url;
                if (selection instanceof URL) {
                    url = (URL) selection;
                } else {
                    url = new URL((String) selection);
                }

                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(url)) {
                    return;
                }

                // Try to display the page
                urlCombo.setEnabled(false); // Disable input
                urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

                timeLabel.setText("");
                timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

                startTime = System.currentTimeMillis();

                // Choose the loading method
                if (onlineLoad.isSelected()) {
                    // Usual load via setPage
                    pane.setPage(url);
                    loadedType.setText(pane.getContentType());
                } else {
                    pane.setContentType("text/html");
                    loadedType.setText(pane.getContentType());
                    if (loader == null) {
                        loader = new HTMLDocumentLoader();
                    }
                    HTMLDocument doc = loader.loadDocument(url);
                    loadComplete();
                    pane.setDocument(doc);
                    displayLoadTime();
                    populateCombo(findLinks(doc, null));
                    enableInput();
                }
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane,
                        new String[] { "Unable to open file", selection.toString() }, "File Open Error",
                        JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                enableInput();
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                enableInput();
            }
        }
    });
}

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

public JComponent build() {
    FormLayout layout = new FormLayout("left:pref, 2dlu, p, 2dlu , p, 2dlu, p, 2dlu, pref:grow",
            "p, 0dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, p, 15dlu, p, 3dlu,p, 3dlu, p,  3dlu, p, 3dlu, p, 3dlu, p,3dlu, p, 3dlu, p, 15dlu, p,3dlu, p, 3dlu, p, 15dlu, p, 3dlu, p");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.DLU4_BORDER);
    builder.setOpaque(true);/*from  w w  w . jav a  2 s  .  co  m*/

    CellConstraints cc = new CellConstraints();

    smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3"));
    smcheckBox.setContentAreaFilled(false);
    smcheckBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setMinimized((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    if (PMS.getConfiguration().isMinimized()) {
        smcheckBox.setSelected(true);
    }

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(Messages.getString("NetworkTab.0"), cc.xy(1, 7));
    final KeyedComboBoxModel kcbm = new KeyedComboBoxModel(
            new Object[] { "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "is", "it",
                    "ja", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv" },
            new Object[] { "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)", "Czech",
                    "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Icelandic",
                    "Italian", "Japanese", "Norwegian", "Polish", "Portuguese", "Portuguese (Brazilian)",
                    "Romanian", "Russian", "Slovenian", "Spanish", "Swedish" });
    langs = new JComboBox(kcbm);
    langs.setEditable(false);
    //langs.setSelectedIndex(0);
    String defaultLang = null;
    if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) {
        defaultLang = configuration.getLanguage();
    } else {
        defaultLang = Locale.getDefault().getLanguage();
    }
    if (defaultLang == null) {
        defaultLang = "en";
    }
    kcbm.setSelectedKey(defaultLang);
    if (langs.getSelectedIndex() == -1) {
        langs.setSelectedIndex(0);
    }

    langs.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setLanguage((String) kcbm.getSelectedKey());

            }
        }
    });
    builder.add(langs, cc.xyw(3, 7, 7));

    builder.add(smcheckBox, cc.xyw(1, 9, 9));

    JButton service = new JButton(Messages.getString("NetworkTab.4"));
    service.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (PMS.get().installWin32Service()) {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"),
                        "Information", JOptionPane.INFORMATION_MESSAGE);

            } else {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.14"), "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    builder.add(service, cc.xy(1, 11));
    if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) {
        service.setEnabled(false);
    }

    host = new JTextField(PMS.getConfiguration().getServerHostname());
    host.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setHostname(host.getText());
            PMS.get().getFrame().setReloadable(true);
        }
    });
    // host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ;
    port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : "");
    port.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            try {
                String p = port.getText();
                if (StringUtils.isEmpty(p)) {
                    p = "5001";
                }
                int ab = Integer.parseInt(p);
                configuration.setServerPort(ab);
                PMS.get().getFrame().setReloadable(true);
            } catch (NumberFormatException nfe) {
            }

        }
    });

    cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), cc.xyw(1, 21, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    ArrayList<String> names = new ArrayList<String>();
    names.add("");
    ArrayList<String> interfaces = new ArrayList<String>();
    interfaces.add("");
    Enumeration<NetworkInterface> enm;
    try {
        enm = NetworkInterface.getNetworkInterfaces();
        while (enm.hasMoreElements()) {
            NetworkInterface ni = enm.nextElement();
            // check for interface has at least one ip address.
            if (ni.getInetAddresses().hasMoreElements()) {
                names.add(ni.getName());
                String displayName = ni.getDisplayName();
                if (displayName == null) {
                    displayName = ni.getName();
                }
                interfaces.add(displayName.trim());
            }
        }
    } catch (SocketException e1) {
        logger.error(null, e1);
    }

    final KeyedComboBoxModel networkInterfaces = new KeyedComboBoxModel(names.toArray(), interfaces.toArray());
    networkinterfacesCBX = new JComboBox(networkInterfaces);
    networkInterfaces.setSelectedKey(configuration.getNetworkInterface());
    networkinterfacesCBX.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey());
                //host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ;
                PMS.get().getFrame().setReloadable(true);
            }
        }
    });

    ip_filter = new JTextField(PMS.getConfiguration().getIpFilter());
    ip_filter.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setIpFilter(ip_filter.getText());
            PMS.get().getFrame().setReloadable(true);
        }
    });

    builder.addLabel(Messages.getString("NetworkTab.20"), cc.xy(1, 23));
    builder.add(networkinterfacesCBX, cc.xyw(3, 23, 7));
    builder.addLabel(Messages.getString("NetworkTab.23"), cc.xy(1, 25));
    builder.add(host, cc.xyw(3, 25, 7));
    builder.addLabel(Messages.getString("NetworkTab.24"), cc.xy(1, 27));
    builder.add(port, cc.xyw(3, 27, 7));
    builder.addLabel(Messages.getString("NetworkTab.30"), cc.xy(1, 29));
    builder.add(ip_filter, cc.xyw(3, 29, 7));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.31"), cc.xyw(1, 31, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32"));
    newHTTPEngine.setSelected(PMS.getConfiguration().isHTTPEngineV2());
    newHTTPEngine.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(newHTTPEngine, cc.xyw(1, 33, 9));

    preventSleep = new JCheckBox(Messages.getString("NetworkTab.33"));
    preventSleep.setSelected(PMS.getConfiguration().isPreventsSleep());
    preventSleep.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(preventSleep, cc.xyw(1, 35, 9));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.34"), cc.xyw(1, 37, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    JPanel panel = builder.getPanel();
    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    return scrollPane;
}

From source file:edu.ucla.stat.SOCR.chart.SuperPowerChart.java

protected void createActionComponents(JToolBar toolBar) {
    JButton button = null;//from  w w  w. ja va2s.co  m

    toolBar.setFloatable(false);

    /**************** Demo Tab****************/
    if (useStaticExample) {
        exampleStaticAction = new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                // Create First Example
                reset();
                resetTable();
                resetMappingList();
                resetExample();
                if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL)
                    setMixPanel();

                updateStatus(url);
                validate();
            }

        };
        button = toolBar.add(exampleStaticAction);
        button.setText(EXAMPLE);
        button.setToolTipText(chartDescription);
    }

    /**************** DO-CHART Tab ****************/
    computeAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            doChart();
        }
    };

    button = toolBar.add(computeAction);
    button.setText(DOCHART);
    button.setToolTipText("Press this Button to Generate the Chart");

    /**************** CLEAR Tab****************/
    clearAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {

            /* somehow reset has to be called more than once to set to the correct header. I'll leave it like this before I figure out why. annie che 20051123 -_- */
            reset(); // Need to work out what this means
            //   reset();

            resetTable();
            resetMappingList();
            resetChart();
            ChartExampleData exampleNull = new ChartExampleData(0, 0);
            /* A Null Example (with no data) is used here
            to reset the table so that when "CLEAR" button is pressed, the cells of dataTable is NOT null. 
            annieche 20060110. */
            updateExample(exampleNull);
            if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL)
                setMixPanel();

            updateStatus("The Chart has been reset!");
            //updateExample(exampleNull);
        }

    };

    button = toolBar.add(clearAction);
    button.setText(CLEAR);
    button.setToolTipText("Clears All Windows");

    /**************** wiki Tab ****************/
    Action linkAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {

            try {
                //popInfo("SOCRChart: About", new java.net.URL("http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity");
                parentApplet.getAppletContext().showDocument(new java.net.URL(
                        "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"),
                        "SOCR: Power Transform Graphing Activity");
            } catch (MalformedURLException Exc) {
                JOptionPane.showMessageDialog(null, Exc, "MalformedURL Error", JOptionPane.ERROR_MESSAGE);
                Exc.printStackTrace();
            }

        }
    };

    button = toolBar.add(linkAction);
    //button.setMinimumSize(new Dimension(110, 20));
    button.setText(" WIKI_Activity ");
    button.setToolTipText("Press this Button to go to SOCR_POWER_Activity wiki page");

    /**************** TEST Tab ****************/
    testAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            doTest();
        }
    };
    if (TEST_API) {
        button = toolBar.add(testAction);
        button.setText(TEST);
        button.setToolTipText("Press this Button to test the API");
    }

}