Example usage for javax.swing JDialog setVisible

List of usage examples for javax.swing JDialog setVisible

Introduction

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

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Dialog depending on the value of parameter b .

Usage

From source file:com.raceup.fsae.test.TesterGui.java

/**
 * Shows dialog with info about unsuccessful test submission
 *///from w  ww . j a v a 2s  .  c  o  m
private void showUnSuccessfulTestSubmissionDialog() {
    totalTestTimer.start(); // re-start total timer

    String message = test.toString();
    message += "\nDon't worry, be happy: this box will automatically " + "close after "
            + Integer.toString(SECONDS_WAIT_BETWEEN_SUBMISSIONS) + " seconds of your " + "submission.\nEnjoy.";

    JOptionPane opt = new JOptionPane(message, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION, null,
            new Object[] {}); // no buttons
    final JDialog dlg = opt.createDialog("Error");
    new Thread(() -> {
        try {
            Thread.sleep(SECONDS_WAIT_BETWEEN_SUBMISSIONS * 1000);
            dlg.dispose();
        } catch (Throwable t) {
            System.err.println(t.toString());
        }
    }).start();
    dlg.setVisible(true);
}

From source file:livecanvas.mesheditor.MeshEditor.java

private void showImage(Image image) {
    if (image == null) {
        return;// w  w w. j av  a2 s .  co  m
    }
    JDialog d = new JDialog(JOptionPane.getFrameForComponent(MeshEditor.this), "Image View", true);
    d.setContentPane(new JLabel(new ImageIcon(image)));
    d.pack();
    d.setLocationRelativeTo(d.getParent());
    d.setVisible(true);
    d.dispose();
}

From source file:com.ga.forms.DailyLogAddUI.java

private void checkInOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkInOutButtonActionPerformed
    DailyLogRecord log = new DailyLogRecord();
    if (DailyLogAddUI.checkIn && !DailyLogAddUI.breakDone) {
        args = new HashMap();
        DailyLogAddUI.breakDone = true;/*from   w  w  w  . jav a 2s . c  o  m*/
        args.put("checked-in", Boolean.toString(DailyLogAddUI.checkIn));
        args.put("had-break", Boolean.toString(DailyLogAddUI.breakDone));
        args.put("checked-out", Boolean.toString(DailyLogAddUI.checkOut));
        if (yesRdButton.isSelected() == true) {
            this.timeOnBreak = "00:30";
        } else if (customRdButton.isSelected() == true) {
            this.timeOnBreak = customBreakTimeTextField.getText();
        } else {
            this.timeOnBreak = "00:00";
        }
        log.setDailyLogRecord(dateDisplayLbl.getText(), dayDisplayLbl.getText(),
                checkInTimeCombo.getSelectedItem().toString(), "", this.timeOnBreak, "", "", "", args);
        doc = (DBObject) JSON.parse(log.getDailyLogRecord().toString());
        args.clear();
        args.put("date", dateDisplayLbl.getText());
        log.updateRecord(doc, args);
    } else if (DailyLogAddUI.checkIn && DailyLogAddUI.breakDone && !DailyLogAddUI.checkOut) {
        args = new HashMap();
        DailyLogAddUI.checkOut = true;
        args.put("checked-in", Boolean.toString(DailyLogAddUI.checkIn));
        args.put("had-break", Boolean.toString(DailyLogAddUI.breakDone));
        args.put("checked-out", Boolean.toString(DailyLogAddUI.checkOut));
        DailyLogDuration durationAgent = new DailyLogDuration();
        durationAgent.calculateCurrentDuration(checkInTimeCombo.getSelectedItem().toString(), this.timeOnBreak,
                checkOutTimeCombo.getSelectedItem().toString());
        this.duration = durationAgent.getCurrentDuration();

        JFrame parent = new JFrame();
        JOptionPane optionPane = new JOptionPane("Duration: " + this.duration + "\n\nDo you want to Check Out?",
                JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
        JDialog msgDialog = optionPane.createDialog(parent, "DLM");
        msgDialog.setVisible(true);

        if (optionPane.getValue().equals(0)) {
            int hours = Integer.parseInt(this.duration.split(":")[0]);
            int minutes = Integer.parseInt(this.duration.split(":")[1]);
            if (hours < 9) {
                durationAgent.calculateUnderTime(this.duration);
                this.underTime = durationAgent.getUnderTime();
                this.overTime = "00:00";
            } else if (hours >= 9 && minutes > 0 && minutes < 60) {
                this.underTime = "00:00";
                durationAgent.calculateOverTime(this.duration);
                this.overTime = durationAgent.getOverTime();

            } else {
                this.underTime = "00:00";
                this.overTime = "00:00";
            }
            log.setDailyLogRecord(dateDisplayLbl.getText(), dayDisplayLbl.getText(),
                    checkInTimeCombo.getSelectedItem().toString(),
                    checkOutTimeCombo.getSelectedItem().toString(), this.timeOnBreak, this.duration,
                    this.underTime, this.overTime, args);
            doc = (DBObject) JSON.parse(log.getDailyLogRecord().toString());
            args.clear();
            args.put("date", dateDisplayLbl.getText());
            log.updateRecord(doc, args);
        } else {
            msgDialog.dispose();
        }
    } else {
        args = new HashMap();
        DailyLogAddUI.checkIn = true;
        args.put("checked-in", Boolean.toString(DailyLogAddUI.checkIn));
        args.put("had-break", Boolean.toString(DailyLogAddUI.breakDone));
        args.put("checked-out", Boolean.toString(DailyLogAddUI.checkOut));
        log.setDailyLogRecord(dateDisplayLbl.getText(), dayDisplayLbl.getText(),
                checkInTimeCombo.getSelectedItem().toString(), "", "", "", "", "", args);
        doc = (DBObject) JSON.parse(log.getDailyLogRecord().toString());
        log.insertRecord(doc);

    }

}

From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java

/**
 * Returns the 'Add child' action./*from  w ww. ja  va2  s. c  o  m*/
 *
 * @return the action
 */
@SuppressWarnings("serial")
private Action getAddChildAction() {
    if (addChildAction == null) {
        String actionCommand = bundle.getString(ADD_CHILD_NODE_KEY);
        String actionKey = bundle.getString(ADD_CHILD_NODE_KEY + ".action");
        addChildAction = new AbstractAction(actionCommand, Icons.ADD) {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("actionPerformed(): action = " + e.getActionCommand());
                if (checkAction()) {
                    model.addNode(StringUtils.removeEnd(nodes[0].getPath(), "/") + "/" + childName,
                            childText.getBytes());
                }
                childName = childText = "";
            }

            private boolean checkAction() {
                JDialog dlg = createAddChildDialog();

                dlg.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                dlg.setSize(800, 600);
                dlg.setLocationRelativeTo(null);
                dlg.setVisible(true);

                boolean nameIsEmpty = childName == null || childName.isEmpty();
                boolean dataIsEmpty = childText == null;
                return !nameIsEmpty && !dataIsEmpty;
            }
        };
        addChildAction.putValue(Action.ACTION_COMMAND_KEY, actionKey);
    }
    return this.addChildAction;
}

From source file:net.lmxm.ute.gui.validation.AbstractInputValidator.java

/**
 * Display messages dialog.//w ww  . j  av a 2  s  . com
 * 
 * @param component the component
 * @param messages the messages
 */
private void displayMessagesDialog(final JComponent component, final List<String> messages) {
    final JDialog dialog = getMessagesDialog();

    // Load dialog with messages.
    getMessagesLabel().setText(StringUtils.join(messages, "\n"));

    // Relocate dialog relative to the input component
    dialog.setSize(0, 0);
    dialog.setLocationRelativeTo(component);
    final Point location = dialog.getLocation();
    final Dimension componentSize = component.getSize();
    dialog.setLocation(location.x - (int) componentSize.getWidth() / 2,
            location.y + (int) componentSize.getHeight() / 2);
    dialog.pack();
    dialog.setVisible(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 av a 2 s .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:net.sf.jabref.openoffice.AutoDetectPaths.java

public JDialog showProgressDialog(JDialog progressParent, String title, String message,
        boolean includeCancelButton) {
    fileSearchCancelled = false;//w w  w.j  a v a2 s. co m
    JProgressBar bar = new JProgressBar(SwingConstants.HORIZONTAL);
    JButton cancel = new JButton(Localization.lang("Cancel"));
    cancel.addActionListener(event -> {
        fileSearchCancelled = true;
        ((JButton) event.getSource()).setEnabled(false);
    });
    final JDialog progressDialog = new JDialog(progressParent, title, false);
    bar.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    bar.setIndeterminate(true);
    if (includeCancelButton) {
        progressDialog.add(cancel, BorderLayout.SOUTH);
    }
    progressDialog.add(new JLabel(message), BorderLayout.NORTH);
    progressDialog.add(bar, BorderLayout.CENTER);
    progressDialog.pack();
    progressDialog.setLocationRelativeTo(null);
    progressDialog.setVisible(true);
    return progressDialog;
}

From source file:Main.java

public Main() {
    super(BoxLayout.Y_AXIS);

    Box info = Box.createVerticalBox();
    info.add(new Label("Please wait 3 seconds"));
    final JButton continueButton = new JButton("Continue");
    info.add(continueButton);/* w  w w.j  av  a2  s .c om*/

    JDialog d = new JDialog();
    d.setModalityType(ModalityType.APPLICATION_MODAL);
    d.setContentPane(info);
    d.pack();

    continueButton.addActionListener(e -> d.dispose());
    continueButton.setVisible(false);

    SwingWorker sw = new SwingWorker<Integer, Integer>() {
        protected Integer doInBackground() throws Exception {
            int i = 0;
            while (i++ < 30) {
                System.out.println(i);
                Thread.sleep(100);
            }
            return null;
        }

        @Override
        protected void done() {
            continueButton.setVisible(true);
        }

    };
    JButton button = new JButton("Click Me");
    button.addActionListener(e -> {
        sw.execute();
        d.setVisible(true);
    });
    add(button);
}

From source file:com.ibm.soatf.gui.SOATestingFrameworkGUI.java

private void displayResultDetails() {
    int rowIdx = jtResults.getSelectedRow();
    Result result = jtResultsModel.getRow(rowIdx);

    JDialog dialog = new ResultsDetailDialog(this, true, result);
    dialog.setVisible(true);
}

From source file:com.ibm.soatf.gui.SOATestingFrameworkGUI.java

private void validateConfig() {
    try {//from www  .j  av a 2s .com
        ConfigConsistencyResult ccr = ConfigurationManager.getInstance().checkConfigConsistency();
        JDialog dialog = new ConfigConsistencyCheckResultDialog(this, true, ccr);
        dialog.setVisible(true);
    } catch (FrameworkConfigurationException ex) {
        logger.warn(ex);
    }
}