javax.swing.JDialog#setName ( )源码实例Demo

下面列出了javax.swing.JDialog#setName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: audiveris   文件: GuiActions.java
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;
}
 
源代码2 项目: audiveris   文件: BookActions.java
/**
 * 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;
    }
}
 
源代码3 项目: libreveris   文件: GuiActions.java
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;
}
 
源代码4 项目: libreveris   文件: ScoreActions.java
/**
 * 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;
    }
}
 
源代码5 项目: snap-desktop   文件: AbstractDialog.java
private void setComponentName(JDialog dialog) {
    if (this.dialog.getName() == null && dialog.getTitle() != null) {
        dialog.setName(dialog.getTitle().toLowerCase().replaceAll(" ", "_"));
    }
}