Example usage for javax.swing JDialog setSize

List of usage examples for javax.swing JDialog setSize

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

The width and height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .

Usage

From source file:coreferenceresolver.gui.MarkupGUI.java

public MarkupGUI() throws IOException {
    highlightPainters = new ArrayList<>();

    for (int i = 0; i < COLORS.length; ++i) {
        DefaultHighlighter.DefaultHighlightPainter highlightPainter = new DefaultHighlighter.DefaultHighlightPainter(
                COLORS[i]);//from   w  ww.j  a  v a2  s . c  om
        highlightPainters.add(highlightPainter);
    }

    defaulPath = FileUtils.readFileToString(new File(".\\src\\coreferenceresolver\\gui\\defaultpath"));
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setLayout(new BorderLayout());
    this.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize());

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    //create menu items
    JMenuItem importMenuItem = new JMenuItem("Import");

    JMenuItem exportMenuItem = new JMenuItem("Export");

    fileMenu.add(importMenuItem);
    fileMenu.add(exportMenuItem);

    menuBar.add(fileMenu);

    this.setJMenuBar(menuBar);

    ScrollablePanel mainPanel = new ScrollablePanel();
    mainPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.NONE);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    //IMPORT BUTTON
    importMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //                MarkupGUI.reviewElements.clear();
            //                MarkupGUI.markupReviews.clear();                
            JFileChooser markupFileChooser = new JFileChooser(defaulPath);
            markupFileChooser.setDialogTitle("Choose your markup file");
            markupFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

            if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                final JDialog d = new JDialog();
                JPanel p1 = new JPanel(new GridBagLayout());
                p1.add(new JLabel("Please Wait..."), new GridBagConstraints());
                d.getContentPane().add(p1);
                d.setSize(100, 100);
                d.setLocationRelativeTo(null);
                d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
                d.setModal(true);

                SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() {
                    protected Void doInBackground() throws IOException, BadLocationException {
                        readMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath());
                        for (int i = 0; i < markupReviews.size(); ++i) {
                            mainPanel.add(newReviewPanel(markupReviews.get(i), i));
                        }
                        return null;
                    }

                    protected void done() {
                        MarkupGUI.this.revalidate();
                        d.dispose();
                    }
                };
                worker.execute();
                d.setVisible(true);
            } else {
                return;
            }
        }
    });

    //EXPORT BUTTON: GET NEW VALUE (REF, TYPE) OF NPs      
    exportMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser markupFileChooser = new JFileChooser(defaulPath);
            markupFileChooser.setDialogTitle("Choose where your markup file saved");
            markupFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                final JDialog d = new JDialog();
                JPanel p1 = new JPanel(new GridBagLayout());
                p1.add(new JLabel("Please Wait..."), new GridBagConstraints());
                d.getContentPane().add(p1);
                d.setSize(100, 100);
                d.setLocationRelativeTo(null);
                d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
                d.setModal(true);

                SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() {
                    protected Void doInBackground() throws IOException {
                        for (Review review : markupReviews) {
                            generateNPsRef(review);
                        }
                        int i = 0;
                        for (ReviewElement reviewElement : reviewElements) {
                            int j = 0;
                            for (Element element : reviewElement.elements) {
                                String newType = element.typeSpinner.getValue().toString();
                                if (newType.equals("Object")) {
                                    markupReviews.get(i).getNounPhrases().get(j).setType(0);
                                } else if (newType.equals("Attribute")) {
                                    markupReviews.get(i).getNounPhrases().get(j).setType(3);
                                } else if (newType.equals("Other")) {
                                    markupReviews.get(i).getNounPhrases().get(j).setType(1);
                                } else if (newType.equals("Candidate")) {
                                    markupReviews.get(i).getNounPhrases().get(j).setType(2);
                                }
                                ++j;
                            }
                            ++i;
                        }
                        initMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath() + File.separator
                                + "markup.out.txt");
                        return null;
                    }

                    protected void done() {
                        d.dispose();
                        try {
                            Desktop.getDesktop()
                                    .open(new File(markupFileChooser.getSelectedFile().getAbsolutePath()));
                        } catch (IOException ex) {
                            Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                };
                worker.execute();
                d.setVisible(true);
            } else {
                return;
            }
        }
    });

    JScrollPane scrollMainPane = new JScrollPane(mainPanel);
    scrollMainPane.getVerticalScrollBar().setUnitIncrement(16);
    scrollMainPane.setPreferredSize(new Dimension(this.getWidth(), this.getHeight()));
    scrollMainPane.setSize(this.getWidth(), this.getHeight());
    this.setResizable(false);
    this.add(scrollMainPane, BorderLayout.CENTER);
    this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    this.pack();
}

From source file:com.aw.swing.mvp.JDialogView.java

private JDialog assembleDialog() {
    String title = getTitle();/* w  w w .j a  v  a  2s.  c  om*/
    JDialog dlg = createDialog(title);

    boolean showAudit = showAuditFields();

    int headerHeight = 0;
    //        int headerHeight = (int) viewLayout.headerPanel.getPreferredSize().getHeight();
    int auditInfoHeight = 0;//(int) viewLayout.auditInfo.getPreferredSize().getHeight();
    int toolbarHeight = 0;
    int errorHeight = 0;
    int contentHeight = (int) viewLayout.contentPanel.getPreferredSize().getHeight();
    int contentWidth = (int) viewLayout.contentPanel.getPreferredSize().getWidth();
    int footerHeight = 0;
    int delta = 40;
    /*        if(contentHeight<=450){
    delta=-160;
            }else if (contentHeight<=700){
    delta=40;
            }*/

    dlg.setSize(contentWidth, (showAudit ? -14 : -14) + headerHeight + toolbarHeight + auditInfoHeight
            + errorHeight + contentHeight + footerHeight + delta);

    return dlg;
}

From source file:com.ixora.rms.ui.RMSFrame.java

/**
 * Launches the job manager tool./*from  w  ww .  j  av  a 2s . c  om*/
 */
private void handleLaunchJobManager() {
    try {
        JDialog jd = new JobManagerDialog(this, getJobEngine(), getJobLibrary(), getHostMonitor());
        jd.setSize(600, 450);
        jd.setModal(false);
        UIUtils.centerDialogAndShow(this, jd);
    } catch (Throwable e) {
        UIExceptionMgr.userException(e);
    }
}

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  .ja va  2 s  .c om
    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:org.fhcrc.cpl.viewer.amt.AmtDatabaseMatcher.java

/**
 * Separating this out so the interesting code flows better
 * @param matchingResult//from   w  w  w . j  a va 2 s. com
 */
public void createMassTimeErrorPlots(FeatureSetMatcher.FeatureMatchingResult matchingResult) {

    int numUnambiguousMatches = 0;
    for (Feature ms1Feature : matchingResult.getMasterSetFeatures()) {
        if (matchingResult.get(ms1Feature).size() == 1)
            numUnambiguousMatches++;
    }
    double[] ms1FeatureMasses = new double[numUnambiguousMatches];
    double[] ms1FeatureHydrophobicities = new double[numUnambiguousMatches];
    double[] massErrorData = new double[numUnambiguousMatches];
    double[] elutionErrorData = new double[numUnambiguousMatches];
    int i = 0;
    for (Feature ms1Feature : matchingResult.getMasterSetFeatures()) {
        ms1FeatureMasses[i] = ms1Feature.getMass();
        ms1FeatureHydrophobicities[i] = AmtExtraInfoDef.getObservedHydrophobicity(ms1Feature);

        if (matchingResult.get(ms1Feature).size() > 1)
            continue;

        Feature matchedAmtFeature = matchingResult.get(ms1Feature).get(0);
        //convert to ppm
        massErrorData[i] = (ms1Feature.getMass() - matchedAmtFeature.getMass())
                * (1000000 / ms1Feature.getMass());
        //System.err.println("Error: " + histogramData[i-1] + ", " +ms1Feature.getMass() + ", " + result.get(ms1Feature).get(0).getMass());

        elutionErrorData[i] = (AmtExtraInfoDef.getObservedHydrophobicity(ms1Feature)
                - (AmtExtraInfoDef.getObservedHydrophobicity(matchedAmtFeature)));
        i++;
    }

    //3D mass-elution histogram
    JDialog perspDialog = new JDialog();
    perspDialog.setSize(1000, 800);
    massTimeErrorPerspectivePlot = new PanelWithRPerspectivePlot();
    massTimeErrorPerspectivePlot.setChartHeight(800);
    massTimeErrorPerspectivePlot.setChartWidth(1000);

    massTimeErrorPerspectivePlot.setSize(1000, 800);
    massTimeErrorPerspectivePlot.setTiltAngle(25);
    massTimeErrorPerspectivePlot.setRotationAngle(-30);
    massTimeErrorPerspectivePlot.setAxisRVariableNames("Hydrophobicity", "Mass_ppm", "Matches");
    double xBinSize = .002;
    double yBinSize = 1;
    massTimeErrorPerspectivePlot.plotPointsSummary(elutionErrorData, massErrorData, xBinSize, yBinSize);
    perspDialog.add(massTimeErrorPerspectivePlot);
    perspDialog.setVisible(true);

    //scatterplot of mass vs. deltaMass
    ScatterPlotDialog spd = new ScatterPlotDialog(ms1FeatureMasses, massErrorData,
            "MS1 feature mass vs. (signed) match mass error");
    spd.setAxisLabels("MS1 Feature Mass", "PPM error (MS1 - AMT)");
    massDeltaMassScatterPlot = spd.getPanelWithScatterPlot().getChart();
    spd.setVisible(true);

    //scatterplot of hydrophobicity error vs. mass error
    ScatterPlotDialog spdHandM = new ScatterPlotDialog(elutionErrorData, massErrorData,
            "MS1 feature mass error vs. H error");
    spdHandM.setAxisLabels("H error", "PPM error");
    spdHandM.setVisible(true);
}

From source file:edu.ku.brc.specify.dbsupport.SpecifyDeleteHelper.java

/**
 * @param workerArg// w w w  .jav a2s . c o  m
 * @param title (already localized)
 * @return a modal dialog showing the progress
 */
public JDialog initProgress(final SwingWorker<?, ?> workerArg, final String title) {
    this.worker = workerArg;

    if (workerArg != null) {
        JDialog dialog = new JDialog((Dialog) null, true);

        titleLbl = new JLabel(title);
        progressBar = new JProgressBar(0, 100);

        CellConstraints cc = new CellConstraints();
        PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g,p,4px,p,f:p:g"));

        pb.add(titleLbl, cc.xy(1, 2));
        pb.add(progressBar, cc.xy(1, 4));
        pb.setDefaultDialogBorder();
        dialog.setContentPane(pb.getPanel());

        dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        dialog.pack();
        dialog.setSize(500, 150);
        workerArg.addPropertyChangeListener(new SwingWorkerCompletionWaiter(dialog));
        return dialog;
    }
    return null;
}

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);
    dialog.setTitle("Updating Launcher");
    dialog.setLocationRelativeTo(App.settings.getParent());
    dialog.setLayout(new FlowLayout());
    dialog.setResizable(false);/*from www.ja va 2 s  .  c  o m*/
    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:userinterface.properties.GUIGraphHandler.java

public void defineConstantsAndPlot(Expression expr, JPanel graph, String seriesName, Boolean isNewGraph,
        boolean is2D) {

    JDialog dialog;
    JButton ok, cancel;//from w w  w . j  av a  2  s  . co m
    JScrollPane scrollPane;
    ConstantPickerList constantList;
    JComboBox<String> xAxis, yAxis;

    //init everything
    dialog = new JDialog(GUIPrism.getGUI());
    dialog.setTitle("Define constants and select axes");
    dialog.setSize(500, 400);
    dialog.setLocationRelativeTo(GUIPrism.getGUI());
    dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS));
    dialog.setModal(true);

    constantList = new ConstantPickerList();
    scrollPane = new JScrollPane(constantList);

    xAxis = new JComboBox<String>();
    yAxis = new JComboBox<String>();

    ok = new JButton("Ok");
    ok.setMnemonic('O');
    cancel = new JButton("Cancel");
    cancel.setMnemonic('C');

    //add all components to their dedicated panels
    JPanel exprPanel = new JPanel(new FlowLayout());
    exprPanel.setBorder(new TitledBorder("Function"));
    exprPanel.add(new JLabel(expr.toString()));

    JPanel axisPanel = new JPanel();
    axisPanel.setBorder(new TitledBorder("Select axis constants"));
    axisPanel.setLayout(new BoxLayout(axisPanel, BoxLayout.Y_AXIS));
    JPanel xAxisPanel = new JPanel(new FlowLayout());
    xAxisPanel.add(new JLabel("X axis:"));
    xAxisPanel.add(xAxis);
    JPanel yAxisPanel = new JPanel(new FlowLayout());
    yAxisPanel.add(new JLabel("Y axis:"));
    yAxisPanel.add(yAxis);
    axisPanel.add(xAxisPanel);
    axisPanel.add(yAxisPanel);

    JPanel constantPanel = new JPanel(new BorderLayout());
    constantPanel.setBorder(new TitledBorder("Please define the following constants"));
    constantPanel.add(scrollPane, BorderLayout.CENTER);
    constantPanel.add(new ConstantHeader(), BorderLayout.NORTH);

    JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    bottomPanel.add(ok);
    bottomPanel.add(cancel);

    //fill the axes components

    for (int i = 0; i < expr.getAllConstants().size(); i++) {

        xAxis.addItem(expr.getAllConstants().get(i));

        if (!is2D)
            yAxis.addItem(expr.getAllConstants().get(i));
    }

    if (!is2D) {
        yAxis.setSelectedIndex(1);
    }

    //fill the constants table

    for (int i = 0; i < expr.getAllConstants().size(); i++) {

        ConstantLine line = new ConstantLine(expr.getAllConstants().get(i), TypeDouble.getInstance());
        constantList.addConstant(line);

        if (!is2D) {
            if (line.getName().equals(xAxis.getSelectedItem().toString())
                    || line.getName().equals(yAxis.getSelectedItem().toString())) {

                line.doFuncEnables(false);
            } else {
                line.doFuncEnables(true);
            }
        }

    }

    //do enables

    if (is2D) {
        yAxis.setEnabled(false);
    }

    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok");
    ok.getActionMap().put("ok", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ok.doClick();
        }
    });

    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "cancel");
    cancel.getActionMap().put("cancel", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cancel.doClick();
        }
    });

    //add action listeners

    xAxis.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (is2D) {
                return;
            }

            String item = xAxis.getSelectedItem().toString();

            if (item.equals(yAxis.getSelectedItem().toString())) {

                int index = yAxis.getSelectedIndex();

                if (index != yAxis.getItemCount() - 1) {
                    yAxis.setSelectedIndex(++index);
                } else {
                    yAxis.setSelectedIndex(--index);
                }

            }

            for (int i = 0; i < constantList.getNumConstants(); i++) {

                ConstantLine line = constantList.getConstantLine(i);

                if (line.getName().equals(xAxis.getSelectedItem().toString())
                        || line.getName().equals(yAxis.getSelectedItem().toString())) {

                    line.doFuncEnables(false);
                } else {

                    line.doFuncEnables(true);
                }

            }
        }
    });

    yAxis.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            String item = yAxis.getSelectedItem().toString();

            if (item.equals(xAxis.getSelectedItem().toString())) {

                int index = xAxis.getSelectedIndex();

                if (index != xAxis.getItemCount() - 1) {
                    xAxis.setSelectedIndex(++index);
                } else {
                    xAxis.setSelectedIndex(--index);
                }
            }

            for (int i = 0; i < constantList.getNumConstants(); i++) {

                ConstantLine line = constantList.getConstantLine(i);

                if (line.getName().equals(xAxis.getSelectedItem().toString())
                        || line.getName().equals(yAxis.getSelectedItem().toString())) {

                    line.doFuncEnables(false);
                } else {

                    line.doFuncEnables(true);
                }

            }
        }
    });

    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            try {

                constantList.checkValid();

            } catch (PrismException e2) {
                JOptionPane.showMessageDialog(dialog,
                        "<html> One or more of the defined constants are invalid. <br><br> <font color=red>Error: </font>"
                                + e2.getMessage() + "</html>",
                        "Parse Error", JOptionPane.ERROR_MESSAGE);
                return;
            }

            if (is2D) {

                // it will always be a parametric graph in 2d case
                ParametricGraph pGraph = (ParametricGraph) graph;

                ConstantLine xAxisConstant = constantList.getConstantLine(xAxis.getSelectedItem().toString());

                if (xAxisConstant == null) {
                    //should never happen
                    JOptionPane.showMessageDialog(dialog, "The selected axis is invalid.", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                double xStartValue = Double.parseDouble(xAxisConstant.getStartValue());
                double xEndValue = Double.parseDouble(xAxisConstant.getEndValue());
                double xStepValue = Double.parseDouble(xAxisConstant.getStepValue());

                int seriesCount = 0;

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line.getName().equals(xAxis.getSelectedItem().toString())) {
                        seriesCount++;
                    } else {

                        seriesCount += line.getTotalNumOfValues();

                    }
                }

                // if there will be too many series to be plotted, ask the user if they are sure they know what they are doing
                if (seriesCount > 10) {

                    int res = JOptionPane.showConfirmDialog(dialog,
                            "This configuration will create " + seriesCount + " series. Continue?", "Confirm",
                            JOptionPane.YES_NO_OPTION);

                    if (res == JOptionPane.NO_OPTION) {
                        return;
                    }

                }

                Values singleValuesGlobal = new Values();

                //add the single values to a global values list

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line.getTotalNumOfValues() == 1) {

                        double singleValue = Double.parseDouble(line.getSingleValue());
                        singleValuesGlobal.addValue(line.getName(), singleValue);
                    }
                }

                // we just have one variable so we can plot directly
                if (constantList.getNumConstants() == 1
                        || singleValuesGlobal.getNumValues() == constantList.getNumConstants() - 1) {

                    SeriesKey key = pGraph.addSeries(seriesName);

                    pGraph.hideShape(key);
                    pGraph.getXAxisSettings().setHeading(xAxis.getSelectedItem().toString());
                    pGraph.getYAxisSettings().setHeading("function");

                    for (double x = xStartValue; x <= xEndValue; x += xStepValue) {

                        double ans = -1;

                        Values vals = new Values();
                        vals.addValue(xAxis.getSelectedItem().toString(), x);

                        for (int ii = 0; ii < singleValuesGlobal.getNumValues(); ii++) {

                            try {
                                vals.addValue(singleValuesGlobal.getName(ii),
                                        singleValuesGlobal.getDoubleValue(ii));
                            } catch (PrismLangException e1) {
                                e1.printStackTrace();
                            }

                        }

                        try {
                            ans = expr.evaluateDouble(vals);
                        } catch (PrismLangException e1) {
                            e1.printStackTrace();
                        }

                        pGraph.addPointToSeries(key, new PrismXYDataItem(x, ans));

                    }

                    if (isNewGraph) {
                        addGraph(pGraph);
                    }

                    dialog.dispose();
                    return;
                }

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line == xAxisConstant || singleValuesGlobal.contains(line.getName())) {
                        continue;
                    }

                    double lineStart = Double.parseDouble(line.getStartValue());
                    double lineEnd = Double.parseDouble(line.getEndValue());
                    double lineStep = Double.parseDouble(line.getStepValue());

                    for (double j = lineStart; j < lineEnd; j += lineStep) {

                        SeriesKey key = pGraph.addSeries(seriesName);
                        pGraph.hideShape(key);

                        for (double x = xStartValue; x <= xEndValue; x += xStepValue) {

                            double ans = -1;

                            Values vals = new Values();
                            vals.addValue(xAxis.getSelectedItem().toString(), x);
                            vals.addValue(line.getName(), j);

                            for (int ii = 0; ii < singleValuesGlobal.getNumValues(); ii++) {

                                try {
                                    vals.addValue(singleValuesGlobal.getName(ii),
                                            singleValuesGlobal.getDoubleValue(ii));
                                } catch (PrismLangException e1) {
                                    // TODO Auto-generated catch block
                                    e1.printStackTrace();
                                }

                            }

                            for (int ii = 0; ii < constantList.getNumConstants(); ii++) {

                                if (constantList.getConstantLine(ii) == xAxisConstant
                                        || singleValuesGlobal
                                                .contains(constantList.getConstantLine(ii).getName())
                                        || constantList.getConstantLine(ii) == line) {

                                    continue;
                                }

                                ConstantLine temp = constantList.getConstantLine(ii);
                                double val = Double.parseDouble(temp.getStartValue());

                                vals.addValue(temp.getName(), val);
                            }

                            try {
                                ans = expr.evaluateDouble(vals);
                            } catch (PrismLangException e1) {
                                e1.printStackTrace();
                            }

                            pGraph.addPointToSeries(key, new PrismXYDataItem(x, ans));
                        }
                    }

                }

                if (isNewGraph) {
                    addGraph(graph);
                }
            } else {

                // this will always be a parametric graph for the 3d case
                ParametricGraph3D pGraph = (ParametricGraph3D) graph;

                //add the graph to the gui
                addGraph(pGraph);

                //Get the constants we want to put on the x and y axis
                ConstantLine xAxisConstant = constantList.getConstantLine(xAxis.getSelectedItem().toString());
                ConstantLine yAxisConstant = constantList.getConstantLine(yAxis.getSelectedItem().toString());

                //add the single values to a global values list

                Values singleValuesGlobal = new Values();

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line.getTotalNumOfValues() == 1) {

                        double singleValue = Double.parseDouble(line.getSingleValue());
                        singleValuesGlobal.addValue(line.getName(), singleValue);
                    }
                }

                pGraph.setGlobalValues(singleValuesGlobal);
                pGraph.setAxisConstants(xAxis.getSelectedItem().toString(), yAxis.getSelectedItem().toString());
                pGraph.setBounds(xAxisConstant.getStartValue(), xAxisConstant.getEndValue(),
                        yAxisConstant.getStartValue(), yAxisConstant.getEndValue());

                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        //plot the graph
                        pGraph.plot(expr.toString(), xAxis.getSelectedItem().toString(), "Function",
                                yAxis.getSelectedItem().toString());

                        //calculate the sampling rates from the step sizes as given by the user

                        int xSamples = (int) ((Double.parseDouble(xAxisConstant.getEndValue())
                                - Double.parseDouble(xAxisConstant.getStartValue()))
                                / Double.parseDouble(xAxisConstant.getStepValue()));
                        int ySamples = (int) ((Double.parseDouble(xAxisConstant.getEndValue())
                                - Double.parseDouble(xAxisConstant.getStartValue()))
                                / Double.parseDouble(xAxisConstant.getStepValue()));

                        pGraph.setSamplingRates(xSamples, ySamples);
                    }
                });

            }

            dialog.dispose();
        }
    });

    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });

    //add everything to the dialog show the dialog

    dialog.add(exprPanel);
    dialog.add(axisPanel);
    dialog.add(constantPanel);
    dialog.add(bottomPanel);
    dialog.setVisible(true);

}

From source file:jeplus.JEPlusFrameMain.java

private void jMenuItemMemoryUsageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemMemoryUsageActionPerformed
    JDialog dialog = new JDialog((JFrame) null, "Memory Usage");
    JPanel_MemoryUsage panel = new JPanel_MemoryUsage("./");
    dialog.getContentPane().add(panel);/*  www .j ava  2 s . c o m*/
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setSize(550, 350);
    dialog.addWindowListener(panel);
    dialog.setLocationRelativeTo(this);
    dialog.setVisible(true);
}

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);
    dialog.setTitle("Updating Launcher");
    dialog.setLocationRelativeTo(App.settings.getParent());
    dialog.setLayout(new FlowLayout());
    dialog.setResizable(false);/*from  w w  w.j  av  a2  s .  c o  m*/
    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);
}