Java Code Examples for javax.swing.JDialog#setName()

The following examples show how to use javax.swing.JDialog#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiActions.java    From audiveris with GNU Affero General Public License v3.0 4 votes vote down vote up
private JDialog createAboutBox ()
{
    StringBuilder rows = new StringBuilder("pref,10dlu,pref,5dlu");

    for (int i = 0; i < (Topic.values().length); i++) {
        rows.append(",pref,3dlu");
    }

    // Layout
    final FormLayout layout = new FormLayout(
            "right:pref, 5dlu, pref, 200dlu",
            rows.toString());
    final PanelBuilder builder = new PanelBuilder(layout);
    final CellConstraints cst = new CellConstraints();

    ///builder.setDefaultDialogBorder();
    int iRow = 1;

    URI uri = UriUtil.toURI(WellKnowns.RES_URI, "splash.png");

    try {
        JPanel logoPanel = new ImagePanel(uri);
        builder.add(logoPanel, cst.xyw(1, iRow, 4));
    } catch (MalformedURLException ex) {
        logger.warn("Error on " + uri, ex);
    }

    iRow += 2;

    JLabel titleLabel = new JLabel();
    titleLabel.setName("aboutTitleLabel");
    builder.add(titleLabel, cst.xyw(1, iRow, 3));

    for (Topic topic : Topic.values()) {
        iRow += 2;

        JLabel label = new JLabel();
        label.setName(topic + "Label");
        builder.add(label, cst.xy(1, iRow));

        topic.comp.setName(topic + "TextField");
        topic.comp.setEditable(false);
        topic.comp.setBorder(null);
        topic.comp.setBackground(Color.WHITE);

        if (topic.comp instanceof JEditorPane) {
            ((JEditorPane) topic.comp).addHyperlinkListener(linkListener);
        }

        builder.add(topic.comp, cst.xy(3, iRow));
    }

    JPanel panel = builder.getPanel();
    panel.setOpaque(true);
    panel.setBackground(Color.WHITE);
    panel.setName("panel");

    JDialog dialog = new JDialog();
    dialog.setName("aboutDialog");
    dialog.add(panel, BorderLayout.CENTER);

    // Manual injection
    resource.injectComponents(dialog);
    Topic.version.comp.setText(WellKnowns.TOOL_REF + ":" + WellKnowns.TOOL_BUILD);
    Topic.classes.comp.setText(WellKnowns.CLASS_CONTAINER.toString());
    Topic.license.comp.setText("GNU Affero GPL v3");

    Topic.ocr.comp.setText(TesseractOCR.getInstance().identify());

    Topic.javaVendor.comp.setText(System.getProperty("java.vendor"));
    Topic.javaVersion.comp.setText(System.getProperty("java.version"));
    Topic.javaRuntime.comp.setText(
            System.getProperty("java.runtime.name") + " (build "
                    + System.getProperty("java.runtime.version")
                    + ")");
    Topic.javaVm.comp.setText(
            System.getProperty("java.vm.name") + " (build "
                    + System.getProperty("java.vm.version")
                    + ", "
                    + System.getProperty("java.vm.info")
                    + ")");
    Topic.os.comp.setText(
            System.getProperty("os.name") + " " + System.getProperty("os.version"));
    Topic.osArch.comp.setText(System.getProperty("os.arch"));

    return dialog;
}
 
Example 2
Source File: BookActions.java    From audiveris with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Prompts the user for interactive confirmation or modification of
 * book/page parameters
 *
 * @param stub the current sheet stub, or null
 * @return true if parameters are applied, false otherwise
 */
private static boolean applyUserSettings (final SheetStub stub)
{
    try {
        final WrappedBoolean apply = new WrappedBoolean(false);
        final ScoreParameters scoreParams = new ScoreParameters(stub);
        final JOptionPane optionPane = new JOptionPane(
                scoreParams.getComponent(),
                JOptionPane.QUESTION_MESSAGE,
                JOptionPane.OK_CANCEL_OPTION);
        final String frameTitle = (stub != null) ? (stub.getBook().getRadix() + " parameters")
                : "General parameters";
        final JDialog dialog = new JDialog(OMR.gui.getFrame(), frameTitle, true); // Modal flag
        dialog.setContentPane(optionPane);
        dialog.setName("scoreParams");

        optionPane.addPropertyChangeListener(new PropertyChangeListener()
        {
            @Override
            public void propertyChange (PropertyChangeEvent e)
            {
                String prop = e.getPropertyName();

                if (dialog.isVisible() && (e.getSource() == optionPane)
                            && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                    Object obj = optionPane.getValue();
                    int value = (Integer) obj;
                    apply.set(value == JOptionPane.OK_OPTION);

                    // Exit only if user gives up or enters correct data
                    if (!apply.isSet() || scoreParams.commit(stub)) {
                        dialog.setVisible(false);
                        dialog.dispose();
                    } else {
                        // Incorrect data, so don't exit yet
                        try {
                            // TODO: Is there a more civilized way?
                            optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
                        } catch (Exception ignored) {
                        }
                    }
                }
            }
        });

        dialog.pack();
        OmrGui.getApplication().show(dialog);

        return apply.value;
    } catch (Exception ex) {
        logger.warn("Error in ScoreParameters", ex);

        return false;
    }
}
 
Example 3
Source File: GuiActions.java    From libreveris with GNU Lesser General Public License v3.0 4 votes vote down vote up
private JDialog createAboutBox ()
{
    StringBuilder rows = new StringBuilder("pref,10dlu,pref,5dlu");

    for (int i = 0; i < (Topic.values().length); i++) {
        rows.append(",pref,3dlu");
    }

    // Layout
    final FormLayout layout = new FormLayout(
            "right:pref, 5dlu, pref, 200dlu",
            rows.toString());
    final PanelBuilder builder = new PanelBuilder(layout);
    final CellConstraints cst = new CellConstraints();

    builder.setDefaultDialogBorder();

    int iRow = 1;

    URI uri = UriUtil.toURI(WellKnowns.RES_URI, "splash.png");

    try {
        JPanel logoPanel = new ImagePanel(uri);
        builder.add(logoPanel, cst.xyw(1, iRow, 4));
    } catch (MalformedURLException ex) {
        logger.warn("Error on " + uri, ex);
    }

    iRow += 2;

    JLabel titleLabel = new JLabel();
    titleLabel.setName("aboutTitleLabel");
    builder.add(titleLabel, cst.xyw(1, iRow, 3));

    for (Topic topic : Topic.values()) {
        iRow += 2;

        JLabel label = new JLabel();
        label.setName(topic + "Label");
        builder.add(label, cst.xy(1, iRow));

        topic.comp.setName(topic + "TextField");
        topic.comp.setEditable(false);
        topic.comp.setBorder(null);
        topic.comp.setBackground(Color.WHITE);

        if (topic.comp instanceof JEditorPane) {
            ((JEditorPane) topic.comp).addHyperlinkListener(
                    linkListener);
        }

        builder.add(topic.comp, cst.xy(3, iRow));
    }

    JPanel panel = builder.getPanel();
    panel.setOpaque(true);
    panel.setBackground(Color.WHITE);
    panel.setName("panel");

    JDialog dialog = new JDialog();
    dialog.setName("aboutDialog");
    dialog.add(panel, BorderLayout.CENTER);

    // Manual injection
    resource.injectComponents(dialog);
    Topic.version.comp.setText(
            WellKnowns.TOOL_REF + ":" + WellKnowns.TOOL_BUILD);
    Topic.classes.comp.setText(WellKnowns.CLASS_CONTAINER.toString());
    Topic.license.comp.setText("GNU GPL V2");

    Topic.javaVendor.comp.setText(System.getProperty("java.vendor"));
    Topic.javaVersion.comp.setText(System.getProperty("java.version"));
    Topic.javaRuntime.comp.setText(
            System.getProperty("java.runtime.name") + " (build "
            + System.getProperty("java.runtime.version") + ")");
    Topic.javaVm.comp.setText(
            System.getProperty("java.vm.name") + " (build "
            + System.getProperty("java.vm.version") + ", "
            + System.getProperty("java.vm.info") + ")");
    Topic.os.comp.setText(
            System.getProperty("os.name") + " "
            + System.getProperty("os.version"));
    Topic.osArch.comp.setText(System.getProperty("os.arch"));

    return dialog;
}
 
Example 4
Source File: ScoreActions.java    From libreveris with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Prompts the user for interactive confirmation or modification of
 * score/page parameters
 *
 * @param sheet the current sheet, or null
 * @return true if parameters are applied, false otherwise
 */
private static boolean applyUserSettings (final Sheet sheet)
{
    try {
        final WrappedBoolean apply = new WrappedBoolean(false);
        final ScoreParameters scoreParams = new ScoreParameters(sheet);
        final JOptionPane optionPane = new JOptionPane(
                scoreParams.getComponent(),
                JOptionPane.QUESTION_MESSAGE,
                JOptionPane.OK_CANCEL_OPTION);
        final String frameTitle = (sheet != null)
                ? (sheet.getScore()
                .getRadix()
                   + " parameters")
                : "General parameters";
        final JDialog dialog = new JDialog(
                Main.getGui().getFrame(),
                frameTitle,
                true); // Modal flag
        dialog.setContentPane(optionPane);
        dialog.setName("scoreParams");

        optionPane.addPropertyChangeListener(
                new PropertyChangeListener()
        {
            @Override
            public void propertyChange (PropertyChangeEvent e)
            {
                String prop = e.getPropertyName();

                if (dialog.isVisible()
                    && (e.getSource() == optionPane)
                    && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                    Object obj = optionPane.getValue();
                    int value = ((Integer) obj).intValue();
                    apply.set(value == JOptionPane.OK_OPTION);

                    // Exit only if user gives up or enters correct data
                    if (!apply.isSet()
                        || scoreParams.commit(sheet)) {
                        dialog.setVisible(false);
                        dialog.dispose();
                    } else {
                        // Incorrect data, so don't exit yet
                        try {
                            // TODO: Is there a more civilized way?
                            optionPane.setValue(
                                    JOptionPane.UNINITIALIZED_VALUE);
                        } catch (Exception ignored) {
                        }
                    }
                }
            }
        });

        dialog.pack();
        MainGui.getInstance()
                .show(dialog);

        return apply.value;
    } catch (Exception ex) {
        logger.warn("Error in ScoreParameters", ex);

        return false;
    }
}
 
Example 5
Source File: AbstractDialog.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void setComponentName(JDialog dialog) {
    if (this.dialog.getName() == null && dialog.getTitle() != null) {
        dialog.setName(dialog.getTitle().toLowerCase().replaceAll(" ", "_"));
    }
}