Example usage for javax.swing JDialog JDialog

List of usage examples for javax.swing JDialog JDialog

Introduction

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

Prototype

public JDialog(Window owner, String title) 

Source Link

Document

Creates a modeless dialog with the specified title and owner Window .

Usage

From source file:emailplugin.MailCreator.java

/**
 * Gives the User the opportunity to specify which Desktop he uses (KDE or
 * Gnome)/*from   www  . ja  v a  2 s .  co  m*/
 *
 * @param parent
 *          Parent Dialog
 * @return true if KDE or Gnome has been selected, false if the User wanted to
 *         specify the App
 */
private boolean showKdeGnomeDialog(Frame parent) {
    final JDialog dialog = new JDialog(parent, true);

    dialog.setTitle(mLocalizer.msg("chooseTitle", "Choose"));

    JPanel panel = (JPanel) dialog.getContentPane();
    panel.setLayout(new FormLayout("10dlu, fill:pref:grow",
            "default, 3dlu, default, 3dlu, default, 3dlu, default, 3dlu:grow, default"));
    panel.setBorder(Borders.DIALOG_BORDER);

    CellConstraints cc = new CellConstraints();

    panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("cantConfigure", "Can't configure on your system")),
            cc.xyw(1, 1, 2));

    JRadioButton kdeButton = new JRadioButton(mLocalizer.msg("kde", "I am using KDE"));
    panel.add(kdeButton, cc.xy(2, 3));

    JRadioButton gnomeButton = new JRadioButton(mLocalizer.msg("gnome", "I am using Gnome"));
    panel.add(gnomeButton, cc.xy(2, 5));

    JRadioButton selfButton = new JRadioButton(mLocalizer.msg("self", "I want to configure by myself"));
    panel.add(selfButton, cc.xy(2, 7));

    ButtonGroup group = new ButtonGroup();
    group.add(kdeButton);
    group.add(gnomeButton);
    group.add(selfButton);

    selfButton.setSelected(true);

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
        }
    });

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.add(ok);
    panel.add(buttonPanel, cc.xy(2, 9));

    UiUtilities.registerForClosing(new WindowClosingIf() {
        public void close() {
            dialog.setVisible(false);
        }

        public JRootPane getRootPane() {
            return dialog.getRootPane();
        }
    });

    dialog.getRootPane().setDefaultButton(ok);

    dialog.pack();
    UiUtilities.centerAndShow(dialog);

    if (kdeButton.isSelected()) {
        mSettings.setApplication("kfmclient");
        mSettings.setParameter("exec {content}");
    } else if (gnomeButton.isSelected()) {
        mSettings.setApplication("gnome-open");
        mSettings.setParameter("{content}");
    } else {
        Plugin.getPluginManager().showSettings(mPlugin);
        return false;
    }

    return true;
}

From source file:org.fhcrc.cpl.viewer.ms2.Fractionation2DUtilities.java

public static void showHeatMapChart(FractionatedAMTDatabaseStructure amtDatabaseStructure,
        double[] dataForChart, String chartName, boolean showLegend) {
    int chartWidth = 1000;
    int chartHeight = 1000;

    double globalMinValue = Double.MAX_VALUE;
    double globalMaxValue = Double.MIN_VALUE;

    for (double value : dataForChart) {
        if (value < globalMinValue)
            globalMinValue = value;//from   w w w  .j  a  v  a2s  .  c o  m
        if (value > globalMaxValue)
            globalMaxValue = value;
    }

    _log.debug("showHeatMapChart: experiment structures:");
    List<double[][]> amtPeptidesInExperiments = new ArrayList<double[][]>();
    for (int i = 0; i < amtDatabaseStructure.getNumExperiments(); i++) {
        int experimentWidth = amtDatabaseStructure.getExperimentStructure(i).columns;
        int experimentHeight = amtDatabaseStructure.getExperimentStructure(i).rows;
        _log.debug("\t" + amtDatabaseStructure.getExperimentStructure(i));
        amtPeptidesInExperiments.add(new double[experimentWidth][experimentHeight]);
    }
    for (int i = 0; i < dataForChart.length; i++) {
        Pair<Integer, int[]> positionInExperiments = amtDatabaseStructure.calculateExperimentAndPosition(i);
        int xpos = positionInExperiments.second[0];
        int ypos = positionInExperiments.second[1];
        int experimentIndex = positionInExperiments.first;
        //System.err.println("i, xpos, ypos: " + i + ", " + xpos + ", " + ypos);            
        amtPeptidesInExperiments.get(experimentIndex)[xpos][ypos] = dataForChart[i];

    }

    JDialog cd = new JDialog(ApplicationContext.getFrame(), "Heat Map(s)");
    cd.setSize(chartWidth, chartHeight);
    cd.setPreferredSize(new Dimension(chartWidth, chartHeight));
    cd.setLayout(new FlowLayout());

    int nextPerfectSquareRoot = 0;
    while (true) {
        nextPerfectSquareRoot++;
        if ((nextPerfectSquareRoot * nextPerfectSquareRoot) >= amtPeptidesInExperiments.size()) {
            break;
        }
    }

    int plotWidth = (int) ((double) (chartWidth - 20) / (double) nextPerfectSquareRoot);
    int plotHeight = (int) ((double) (chartHeight - 20) / (double) nextPerfectSquareRoot);

    _log.debug("Rescaled chart dimensions: " + plotWidth + "x" + plotHeight);

    LookupPaintScale paintScale = PanelWithHeatMap.createPaintScale(globalMinValue, globalMaxValue, Color.BLUE,
            Color.RED);

    for (int i = 0; i < amtPeptidesInExperiments.size(); i++) {
        PanelWithHeatMap pwhm = new PanelWithHeatMap(amtPeptidesInExperiments.get(i), "Experiment " + (i + 1));
        //            pwhm.setPalette(PanelWithHeatMap.PALETTE_BLUE_RED);
        pwhm.setPaintScale(paintScale);
        pwhm.setPreferredSize(new Dimension(plotWidth, plotHeight));
        pwhm.setAxisLabels("AX Fraction", "RP Fraction");
        if (!showLegend)
            pwhm.getChart().removeLegend();
        cd.add(pwhm);
    }
    cd.setTitle(chartName);
    cd.setVisible(true);
}

From source file:dk.cubing.liveresults.uploader.engine.ResultsEngine.java

/**
 * Create preferences dialog/* w w  w .  j  a v  a 2s . co  m*/
 */
public void createAndShowPreferencesDialog() {
    JDialog dialog = new JDialog(frame, "Preferences");
    dialog.add(new PreferencesPanel(dialog, this));
    dialog.setResizable(false);
    dialog.pack();
    dialog.setVisible(true);
}

From source file:net.sf.jabref.gui.fieldeditors.FileListEditor.java

public void autoSetLinks() {
    auto.setEnabled(false);// w ww .  j a v  a 2 s.  c om

    Collection<BibEntry> entries = new ArrayList<>();
    entries.addAll(frame.getCurrentBasePanel().getSelectedEntries());

    // filesystem lookup
    JDialog dialog = new JDialog(frame, true);
    JabRefExecutorService.INSTANCE
            .execute(AutoSetLinks.autoSetLinks(entries, null, null, tableModel, databaseContext, e -> {
                auto.setEnabled(true);

                if (e.getID() > 0) {
                    entryEditor.updateField(this);
                    adjustColumnWidth();
                    frame.output(Localization.lang("Finished automatically setting external links."));
                } else {
                    frame.output(Localization.lang("Finished automatically setting external links.") + " "
                            + Localization.lang("No files found."));

                    // auto download file as no file found before
                    frame.getCurrentBasePanel().runCommand(Actions.DOWNLOAD_FULL_TEXT);
                }
                // reset
                auto.setEnabled(true);
            }, dialog));
}

From source file:com.paniclauncher.data.Settings.java

public void reloadLauncherData() {
    log("Updating Launcher Data");
    final JDialog dialog = new JDialog(this.parent, ModalityType.APPLICATION_MODAL);
    dialog.setSize(300, 100);/*from ww w .  ja v a 2 s  .c  o m*/
    dialog.setTitle("Updating Launcher");
    dialog.setLocationRelativeTo(App.settings.getParent());
    dialog.setLayout(new FlowLayout());
    dialog.setResizable(false);
    dialog.add(new JLabel("Updating Launcher... Please Wait"));
    Thread updateThread = new Thread() {
        public void run() {
            checkForUpdatedFiles(); // Download all updated files
            reloadNewsPanel(); // Reload news panel
            loadPacks(); // Load the Packs available in the Launcher
            loadUsers(); // Load the Testers and Allowed Players for the packs
            reloadPacksPanel(); // Reload packs panel
            loadAddons(); // Load the Addons available in the Launcher
            loadInstances(); // Load the users installed Instances
            reloadInstancesPanel(); // Reload instances panel
            dialog.setVisible(false); // Remove the dialog
            dialog.dispose(); // Dispose the dialog
        };
    };
    updateThread.start();
    dialog.setVisible(true);
}

From source file:fll.subjective.SubjectiveFrame.java

/**
 * Show differences.//from   w w w . ja v  a  2s.c  o m
 */
private void showDifferencesDialog(final Collection<SubjectiveScoreDifference> diffs) {
    final SubjectiveDiffTableModel model = new SubjectiveDiffTableModel(diffs);
    final JTable table = new JTable(model);
    table.setGridColor(Color.BLACK);

    table.addMouseListener(new MouseAdapter() {
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                final JTable target = (JTable) e.getSource();
                final int row = target.getSelectedRow();

                final SubjectiveScoreDifference diff = model.getDiffForRow(row);

                // find correct table
                final String category = diff.getCategory();
                final JTable scoreTable = getTableForTitle(category);
                final int tabIndex = getTabIndexForCategory(category);
                getTabbedPane().setSelectedIndex(tabIndex);

                // get correct row and column
                final SubjectiveTableModel model = (SubjectiveTableModel) scoreTable.getModel();
                final int scoreRow = model.getRowForTeamAndJudge(diff.getTeamNumber(), diff.getJudge());
                final int scoreCol = model.getColForSubcategory(diff.getSubcategory());
                if (scoreRow == -1 || scoreCol == -1) {
                    throw new FLLRuntimeException(
                            "Internal error: Cannot find correct row and column for score difference: " + diff);
                }

                scoreTable.changeSelection(scoreRow, scoreCol, false, false);
            }
        }
    });

    final JDialog dialog = new JDialog(this, false);
    final Container cpane = dialog.getContentPane();
    cpane.setLayout(new BorderLayout());
    final JScrollPane tableScroller = new JScrollPane(table);
    cpane.add(tableScroller, BorderLayout.CENTER);

    dialog.pack();
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setVisible(true);
}

From source file:fll.subjective.SubjectiveFrame.java

/**
 * Make sure the data in the table is valid. This checks to make sure that for
 * all rows, all columns that contain numeric data are actually set, or none
 * of these columns are set in a row. This avoids the case of partial data.
 * This method is fail fast in that it will display a dialog box on the first
 * error it finds.//from w  ww .j a  va 2  s  . co m
 * 
 * @return true if everything is ok
 */
@SuppressFBWarnings(value = "SIC_INNER_SHOULD_BE_STATIC_ANON", justification = "Static inner class to replace anonomous listener isn't worth the confusion of finding the class definition")
private boolean validateData() {
    stopCellEditors();

    final List<String> warnings = new LinkedList<String>();
    for (final ScoreCategory subjectiveCategory : getChallengeDescription().getSubjectiveCategories()) {
        final String category = subjectiveCategory.getName();
        final String categoryTitle = subjectiveCategory.getTitle();

        final List<AbstractGoal> goals = subjectiveCategory.getGoals();
        final List<Element> scoreElements = SubjectiveTableModel.getScoreElements(_scoreDocument, category);
        for (final Element scoreElement : scoreElements) {
            int numValues = 0;
            for (final AbstractGoal goal : goals) {
                final String goalName = goal.getName();

                final Element subEle = SubjectiveUtils.getSubscoreElement(scoreElement, goalName);
                if (null != subEle) {
                    final String value = subEle.getAttribute("value");
                    if (!value.isEmpty()) {
                        numValues++;
                    }
                }
            }
            if (numValues != goals.size() && numValues != 0) {
                warnings.add(categoryTitle + ": " + scoreElement.getAttribute("teamNumber")
                        + " has too few scores (needs all or none): " + numValues);
            }

        }
    }

    if (!warnings.isEmpty()) {
        // join the warnings with carriage returns and display them
        final StyledDocument doc = new DefaultStyledDocument();
        for (final String warning : warnings) {
            try {
                doc.insertString(doc.getLength(), warning + "\n", null);
            } catch (final BadLocationException ble) {
                throw new RuntimeException(ble);
            }
        }
        final JDialog dialog = new JDialog(this, "Warnings");
        final Container cpane = dialog.getContentPane();
        cpane.setLayout(new BorderLayout());
        final JButton okButton = new JButton("Ok");
        cpane.add(okButton, BorderLayout.SOUTH);
        okButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent ae) {
                dialog.setVisible(false);
                dialog.dispose();
            }
        });
        cpane.add(new JTextPane(doc), BorderLayout.CENTER);
        dialog.pack();
        dialog.setVisible(true);
        return false;
    } else {
        return true;
    }
}

From source file:com.peterbochs.sourceleveldebugger.SourceLevelDebugger3.java

public void loadELF(String elfPaths[]) {
    final JDialog dialog = new JDialog(peterBochsDebugger, true);
    JLabel jLabel = new JLabel();
    jLabel.setHorizontalAlignment(JTextField.CENTER);
    dialog.setContentPane(jLabel);//from   w  ww.  j  a v  a2s  .c o m
    dialog.setSize(500, 100);
    dialog.setLocationRelativeTo(peterBochsDebugger);
    new Thread(new Runnable() {
        @Override
        public void run() {
            dialog.setVisible(true);
        }
    }).start();

    //$hide>>$
    if (Global.debug) {
        System.out.println("load elf");
    }

    for (String elfPath : elfPaths) {
        File file;
        long memoryOffset = 0;

        if (elfPath.contains("=")) {
            memoryOffset = CommonLib.string2long(elfPath.split("=")[1]);
            file = new File(elfPath.split("=")[0]);
        } else {
            file = new File(elfPath);
        }
        loadELF(file, dialog, memoryOffset);
    }

    if (Global.debug) {
        System.out.println("load elf end");
    }
    //$hide<<$

    dialog.setVisible(false);
}

From source file:com.atlauncher.data.Settings.java

public void reloadLauncherData() {
    final JDialog dialog = new JDialog(this.parent, ModalityType.APPLICATION_MODAL);
    dialog.setSize(300, 100);// w w  w . ja  va  2s . c o m
    dialog.setTitle("Updating Launcher");
    dialog.setLocationRelativeTo(App.settings.getParent());
    dialog.setLayout(new FlowLayout());
    dialog.setResizable(false);
    dialog.add(new JLabel("Updating Launcher... Please Wait"));
    App.TASKPOOL.execute(new Runnable() {

        @Override
        public void run() {
            if (hasUpdatedFiles()) {
                downloadUpdatedFiles(); // Downloads updated files on the server
            }
            checkForLauncherUpdate();
            loadNews(); // Load the news
            reloadNewsPanel(); // Reload news panel
            loadPacks(); // Load the Packs available in the Launcher
            reloadPacksPanel(); // Reload packs panel
            loadUsers(); // Load the Testers and Allowed Players for the packs
            loadInstances(); // Load the users installed Instances
            reloadInstancesPanel(); // Reload instances panel
            dialog.setVisible(false); // Remove the dialog
            dialog.dispose(); // Dispose the dialog
        }
    });
    dialog.setVisible(true);
}

From source file:ffx.ui.MainPanel.java

/**
 * <p>/*w w w . ja  v  a  2  s.co m*/
 * initialize</p>
 */
public void initialize() {
    if (init) {
        return;
    }
    init = true;
    String dir = System.getProperty("user.dir",
            FileSystemView.getFileSystemView().getDefaultDirectory().getAbsolutePath());
    setCWD(new File(dir));
    locale = new FFXLocale("en", "US");
    JDialog splashScreen = null;
    ClassLoader loader = getClass().getClassLoader();
    if (!GraphicsEnvironment.isHeadless()) {
        // Splash Screen
        JFrame.setDefaultLookAndFeelDecorated(true);
        splashScreen = new JDialog(frame, false);
        ImageIcon logo = new ImageIcon(loader.getResource("ffx/ui/icons/splash.png"));
        JLabel ffxLabel = new JLabel(logo);
        ffxLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
        Container contentpane = splashScreen.getContentPane();
        contentpane.setLayout(new BorderLayout());
        contentpane.add(ffxLabel, BorderLayout.CENTER);
        splashScreen.setUndecorated(true);
        splashScreen.pack();
        Dimension screenDimension = getToolkit().getScreenSize();
        Dimension splashDimension = splashScreen.getSize();
        splashScreen.setLocation((screenDimension.width - splashDimension.width) / 2,
                (screenDimension.height - splashDimension.height) / 2);
        splashScreen.setResizable(false);
        splashScreen.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        splashScreen.setVisible(true);
        // Make all pop-up Menus Heavyweight so they play nicely with Java3D
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    }
    // Create the Root Node
    dataRoot = new MSRoot();
    Border bb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    statusLabel = new JLabel("  ");
    JLabel stepLabel = new JLabel("  ");
    stepLabel.setHorizontalAlignment(JLabel.RIGHT);
    JLabel energyLabel = new JLabel("  ");
    energyLabel.setHorizontalAlignment(JLabel.RIGHT);
    JPanel statusPanel = new JPanel(new GridLayout(1, 3));
    statusPanel.setBorder(bb);
    statusPanel.add(statusLabel);
    statusPanel.add(stepLabel);
    statusPanel.add(energyLabel);
    if (!GraphicsEnvironment.isHeadless()) {
        GraphicsConfigTemplate3D template3D = new GraphicsConfigTemplate3D();
        template3D.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED);
        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getBestConfiguration(template3D);
        graphicsCanvas = new GraphicsCanvas(gc, this);
        graphicsPanel = new GraphicsPanel(graphicsCanvas, statusPanel);
    }
    // Initialize various Panels
    hierarchy = new Hierarchy(this);
    hierarchy.setStatus(statusLabel, stepLabel, energyLabel);
    keywordPanel = new KeywordPanel(this);
    modelingPanel = new ModelingPanel(this);
    JPanel treePane = new JPanel(new BorderLayout());
    JScrollPane scrollPane = new JScrollPane(hierarchy, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    treePane.add(scrollPane, BorderLayout.CENTER);
    tabbedPane = new JTabbedPane();

    ImageIcon graphicsIcon = new ImageIcon(loader.getResource("ffx/ui/icons/monitor.png"));
    ImageIcon keywordIcon = new ImageIcon(loader.getResource("ffx/ui/icons/key.png"));
    ImageIcon modelingIcon = new ImageIcon(loader.getResource("ffx/ui/icons/cog.png"));
    tabbedPane.addTab(locale.getValue("Graphics"), graphicsIcon, graphicsPanel);
    tabbedPane.addTab(locale.getValue("KeywordEditor"), keywordIcon, keywordPanel);
    tabbedPane.addTab(locale.getValue("ModelingCommands"), modelingIcon, modelingPanel);
    tabbedPane.addChangeListener(this);
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, tabbedPane);

    /* splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false,
     treePane, graphicsPanel); */
    splitPane.setResizeWeight(0.25);
    splitPane.setOneTouchExpandable(true);
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    if (!GraphicsEnvironment.isHeadless()) {
        mainMenu = new MainMenu(this);
        add(mainMenu.getToolBar(), BorderLayout.NORTH);
        getModelingShell();
        loadPrefs();
        SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this));
        splashScreen.dispose();
    }
}