Example usage for javax.swing JFrame dispose

List of usage examples for javax.swing JFrame dispose

Introduction

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

Prototype

public void dispose() 

Source Link

Document

Releases all of the native screen resources used by this Window , its subcomponents, and all of its owned children.

Usage

From source file:de.jakop.ngcalsync.application.TrayStarter.java

private ActionListener createExitActionListener(final JFrame logWindow, final JFrame aboutWindow) {
    return new ActionListener() {

        @Override/*from   w  ww  .  j  a va 2  s  . c  o m*/
        public void actionPerformed(final ActionEvent e) {
            logWindow.dispose();
            aboutWindow.dispose();
            System.exit(0);
        }
    };
}

From source file:org.geotools.renderer.chart.GeometryRendererTest.java

void showChart(XYPlot plot) throws Exception {
    JFreeChart chart = new JFreeChart(plot);
    chart.setAntiAlias(true);//from  w  w  w.  j  av  a 2  s  .  co m
    ChartPanel panel = new ChartPanel(chart, true);

    final String headless = System.getProperty("java.awt.headless", "false");
    if (!headless.equalsIgnoreCase("true") && TestData.isInteractiveTest()) {
        try {
            JFrame frame = new JFrame(getName());
            frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    e.getWindow().dispose();
                }
            });
            frame.setContentPane(panel);
            frame.setSize(new Dimension(500, 500));
            frame.setVisible(true);

            Thread.sleep(5000);
            frame.dispose();
        } catch (HeadlessException exception) {
            // The test is running on a machine without X11 display. Ignore.
            return;
        }
    }
}

From source file:gui.images.CodebookVectorProfilePanel.java

/**
 * Sets the data to be shown./*  w w w  .ja va 2s. c om*/
 *
 * @param occurrenceProfile Double array that is the neighbor occurrence
 * profile of this visual word.
 * @param codebookIndex Integer that is the index of this visual word.
 * @param classColors Color[] of class colors.
 * @param classNames String[] of class names.
 */
public void setResults(double[] occurrenceProfile, int codebookIndex, Color[] classColors,
        String[] classNames) {
    int numClasses = Math.min(classNames.length, occurrenceProfile.length);
    this.codebookIndex = codebookIndex;
    this.occurrenceProfile = occurrenceProfile;
    DefaultPieDataset pieData = new DefaultPieDataset();
    for (int cIndex = 0; cIndex < numClasses; cIndex++) {
        pieData.setValue(classNames[cIndex], occurrenceProfile[cIndex]);
    }
    JFreeChart chart = ChartFactory.createPieChart3D("codebook vect " + codebookIndex, pieData, true, true,
            false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    PieRenderer prend = new PieRenderer(classColors);
    prend.setColor(plot, pieData);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(140, 140));
    chartPanel.setVisible(true);
    chartPanel.revalidate();
    chartPanel.repaint();
    JPanel jp = new JPanel();
    jp.setPreferredSize(new Dimension(140, 140));
    jp.setMinimumSize(new Dimension(140, 140));
    jp.setMaximumSize(new Dimension(140, 140));
    jp.setSize(new Dimension(140, 140));
    jp.setLayout(new FlowLayout());
    jp.add(chartPanel);
    jp.setVisible(true);
    jp.validate();
    jp.repaint();

    JFrame frame = new JFrame();
    frame.setBackground(Color.WHITE);
    frame.setUndecorated(true);
    frame.getContentPane().add(jp);
    frame.pack();
    BufferedImage bi = new BufferedImage(jp.getWidth(), jp.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D graphics = bi.createGraphics();
    jp.print(graphics);
    graphics.dispose();
    frame.dispose();
    imPanel.removeAll();
    imPanel.setImage(bi);
    imPanel.setVisible(true);
    imPanel.revalidate();
    imPanel.repaint();
}

From source file:com.polivoto.threading.IncommingRequestHandler.java

private void yaVasAEmpezar() {
    final long startingMillis = new java.util.Date().getTime();
    EsperanzaDeTiempo esperanzaDeTiempo = new EsperanzaDeTiempo(1, 1, accionesConsultor, (long) 3.6e5,
            new EsperanzaDeTiempo.TimeToCookAction() {

                @Override/*from ww  w.  j  av a2s .  c o  m*/
                public void coocked(Long esperanzaCalculada, String status) {
                    long finishingMillis = new java.util.Date().getTime();
                    if ("Ok".equals(status)) {
                        LogProvider.logMessage(getClass().getName(),
                                "Terminamos a las: " + ProveedorDeRecursos.obtenerFecha());
                        LogProvider.logMessage(getClass().getName(), "Tiempo total: "
                                + ProveedorDeRecursos.obtenerFormatoEnHoras(finishingMillis - startingMillis));
                        LogProvider.logMessage(getClass().getName(),
                                "Esperanza calculada: " + esperanzaCalculada);
                        //continuar(esperanzaCalculada);
                    } else {
                        final JFrame f = new JFrame();
                        new java.util.Timer().schedule(new java.util.TimerTask() {
                            @Override
                            public void run() {
                                f.dispose();
                            }
                        }, 2700);
                        JOptionPane.showMessageDialog(f, status);
                    }
                }
            });
    LogProvider.logMessage(getClass().getName(), "Iniciamos a las: " + ProveedorDeRecursos.obtenerFecha());
    esperanzaDeTiempo.bake();
}

From source file:com.seanmadden.net.fast.FastInterpretype.java

public void configEditWindow() {
    final JFrame frame = new JFrame();
    final Vector<ConfigOption> components = new Vector<ConfigOption>();
    JPanel buttons = new JPanel(new GridLayout(1, 2));
    JButton ok = new JButton("Save");
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (ConfigOption config : components) {
                config.actionPerformed(null);
            }//from  ww  w.  j av  a 2  s  . c om
            frame.dispose();
            try {
                FileWriter writer = new FileWriter(filename);
                config.write(writer);
                writer.flush();
                writer.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            } catch (JSONException ex) {
                ex.printStackTrace();
            }
        }

    });
    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            frame.dispose();
        }
    });
    buttons.add(ok);
    buttons.add(cancel);
    Iterator<String> rator = config.keys();
    int size = 0;
    try {
        while (rator.hasNext()) {
            String key = (String) rator.next();
            ConfigOption config = new ConfigOption(key, this.config.getString(key));
            frame.add(config);
            components.add(config);
            ++size;
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    frame.setLayout(new GridLayout(size + 1, 1));
    frame.add(buttons);
    frame.setSize(300, 400);
    frame.pack();
    frame.setVisible(true);
}

From source file:herramientas.Ecualizacion_histograma.java

private void controles() {
    final JFrame v = new JFrame();
    v.setSize(220, 120);//  w w  w  . j a va 2  s  .  co m
    v.setVisible(true);
    v.setTitle("Controles");
    v.setResizable(false);

    JPanel panel = new JPanel();
    v.add(panel);

    JButton Hist = new JButton("Histograma");
    Hist.setSize(220, 30);
    panel.add(Hist);
    JButton Hist_ac = new JButton("Histograma Acumulativo");
    panel.add(Hist_ac);
    JButton Hist_ec = new JButton("Histograma Ecualizado");
    panel.add(Hist_ec);

    Hist.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            v.dispose();
            histograma();
        }
    });

    Hist_ac.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            v.dispose();
            histogramaAcumulativo();
        }
    });

    Hist_ec.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //                ecualizacion();
            v.dispose();
            gestor_img.anadirImagen(ecualizacion());
        }
    });

}

From source file:com.ywh.train.logic.TrainClient.java

/**
 * url??/* w  ww .jav  a 2  s .  co m*/
 * @param url
 * @return
 * @throws IOException
 */

String getCode(String url) throws IOException {
    JFrame frame = new JFrame("??");
    JLabel label = new JLabel(new ImageIcon(getCodeByte(url)), JLabel.CENTER);
    frame.add(label);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
    String rd = br.readLine();
    frame.dispose();
    return rd;
}

From source file:gov.nih.nci.nbia.StandaloneDMV3.java

public void launch(List<String> seriesList) {
    checkCompatibility();//from   w ww  .  ja v a 2  s.c o m
    if ((seriesList == null) || (seriesList.size() <= 0)) {
        JOptionPane.showMessageDialog(null,
                "This version of Download App requires to have at least one series instance UID in manifest file.");
        System.exit(0);
    } else {
        this.seriesList = seriesList;
        if (seriesList.size() > 9999) {
            int result = JOptionPane.showConfirmDialog(null,
                    "The number of series in manifest file exceeds the maximum 9,999 series threshold. Only the first 9,999 series will be downloaded.",
                    "Threshold Exceeded Notification", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.INFORMATION_MESSAGE);

            if (result != JOptionPane.OK_OPTION) {
                System.exit(0);
            }
        }

        JFrame f;
        String os = System.getProperty("os.name").toLowerCase();
        if (os.startsWith("mac")) {
            f = showProgressForMac("Loading your data");
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createMainWin();
                    f.setVisible(false);
                    f.dispose();
                }
            });
        } else {
            f = showProgress("Loading your data");
            createMainWin();
            f.setVisible(false);
            f.dispose();
        }
    }
}

From source file:ConfigFiles.java

public ConfigFiles(Dimension screensize) {
    //         initializeFileBrowser();
    paths = new JPanel();
    paths.setBackground(Color.WHITE);
    //paths.setBorder(BorderFactory.createTitledBorder("Paths"));
    paths.setLayout(null);/*  w ww .j av  a  2s  .  c o  m*/
    paths.setPreferredSize(new Dimension(930, 1144));
    paths.setSize(new Dimension(930, 1144));
    paths.setMinimumSize(new Dimension(930, 1144));
    paths.setMaximumSize(new Dimension(930, 1144));
    //paths.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    setLayout(null);
    ttcpath = new JTextField();
    addPanel("TestCase Source Path",
            "Master directory with the test cases that can" + " be run by the framework", ttcpath,
            RunnerRepository.TESTSUITEPATH, 10, true, null);
    tMasterXML = new JTextField();
    tUsers = new JTextField();

    addPanel("Projects Path", "Location of projects XML files", tUsers, RunnerRepository.REMOTEUSERSDIRECTORY,
            83, true, null);

    tSuites = new JTextField();
    addPanel("Predefined Suites Path", "Location of predefined suites", tSuites,
            RunnerRepository.PREDEFINEDSUITES, 156, true, null);

    testconfigpath = new JTextField();
    addPanel("Test Configuration Path", "Test Configuration path", testconfigpath,
            RunnerRepository.TESTCONFIGPATH, 303, true, null);

    tepid = new JTextField();
    addPanel("EP name File", "Location of the file that contains" + " the Ep name list", tepid,
            RunnerRepository.REMOTEEPIDDIR, 595, true, null);
    tlog = new JTextField();
    addPanel("Logs Path", "Location of the directory that stores the most recent log files."
            + " The files are re-used each Run.", tlog, RunnerRepository.LOGSPATH, 667, true, null);
    tsecondarylog = new JTextField();

    JPanel p = addPanel("Secondary Logs Path",
            "Location of the directory that archives copies of the most recent log files, with"
                    + " original file names appended with <.epoch time>",
            tsecondarylog, RunnerRepository.SECONDARYLOGSPATH, 930, true, null);
    logsenabled.setSelected(Boolean.parseBoolean(RunnerRepository.PATHENABLED));
    logsenabled.setBackground(Color.WHITE);
    p.add(logsenabled);

    JPanel p7 = new JPanel();
    p7.setBackground(Color.WHITE);
    TitledBorder border7 = BorderFactory.createTitledBorder("Log Files");
    border7.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border7.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p7.setBorder(border7);
    p7.setLayout(new BoxLayout(p7, BoxLayout.Y_AXIS));
    p7.setBounds(80, 740, 800, 190);
    paths.add(p7);
    JTextArea log2 = new JTextArea("All the log files that will be monitored");
    log2.setWrapStyleWord(true);
    log2.setLineWrap(true);
    log2.setEditable(false);
    log2.setCursor(null);
    log2.setOpaque(false);
    log2.setFocusable(false);
    log2.setBorder(null);
    log2.setFont(new Font("Arial", Font.PLAIN, 12));
    log2.setBackground(getBackground());
    log2.setMaximumSize(new Dimension(170, 25));
    log2.setPreferredSize(new Dimension(170, 25));
    JPanel p71 = new JPanel();
    p71.setBackground(Color.WHITE);
    p71.setLayout(new GridLayout());
    p71.setMaximumSize(new Dimension(700, 13));
    p71.setPreferredSize(new Dimension(700, 13));
    p71.add(log2);
    JPanel p72 = new JPanel();
    p72.setBackground(Color.WHITE);
    p72.setLayout(new BoxLayout(p72, BoxLayout.Y_AXIS));
    trunning = new JTextField();
    p72.add(addField(trunning, "Running: ", 0));
    tdebug = new JTextField();
    p72.add(addField(tdebug, "Debug: ", 1));
    tsummary = new JTextField();
    p72.add(addField(tsummary, "Summary: ", 2));
    tinfo = new JTextField();
    p72.add(addField(tinfo, "Info: ", 3));
    tcli = new JTextField();
    p72.add(addField(tcli, "Cli: ", 4));
    p7.add(p71);
    p7.add(p72);
    libpath = new JTextField();

    addPanel("Library path", "Secondary user library path", libpath, RunnerRepository.REMOTELIBRARY, 229, true,
            null);

    JPanel p8 = new JPanel();
    p8.setBackground(Color.WHITE);
    TitledBorder border8 = BorderFactory.createTitledBorder("File");
    border8.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border8.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p8.setBorder(border8);
    p8.setLayout(null);
    p8.setBounds(80, 1076, 800, 50);
    if (PermissionValidator.canChangeFWM()) {
        paths.add(p8);
    }
    JButton save = new JButton("Save");
    save.setToolTipText("Save and automatically load config");
    save.setBounds(490, 20, 70, 20);
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            saveXML(false, "fwmconfig");
            loadConfig("fwmconfig.xml");
        }
    });
    p8.add(save);
    //         if(!PermissionValidator.canChangeFWM()){
    //             save.setEnabled(false);
    //         }
    JButton saveas = new JButton("Save as");
    saveas.setBounds(570, 20, 90, 20);
    saveas.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            String filename = CustomDialog.showInputDialog(JOptionPane.QUESTION_MESSAGE,
                    JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "File Name", "Please enter file name");
            if (!filename.equals("NULL")) {
                saveXML(false, filename);
            }
        }
    });
    p8.add(saveas);

    final JButton loadXML = new JButton("Load Config");
    loadXML.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            try {
                String[] configs = RunnerRepository
                        .getRemoteFolderContent(RunnerRepository.USERHOME + "/twister/config/");
                JComboBox combo = new JComboBox(configs);
                int resp = (Integer) CustomDialog.showDialog(combo, JOptionPane.INFORMATION_MESSAGE,
                        JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "Config", null);
                final String config;
                if (resp == JOptionPane.OK_OPTION)
                    config = combo.getSelectedItem().toString();
                else
                    config = null;
                if (config != null) {
                    new Thread() {
                        public void run() {
                            setEnabledTabs(false);
                            JFrame progress = new JFrame();
                            progress.setAlwaysOnTop(true);
                            progress.setLocation((int) loadXML.getLocationOnScreen().getX(),
                                    (int) loadXML.getLocationOnScreen().getY());
                            progress.setUndecorated(true);
                            JProgressBar bar = new JProgressBar();
                            bar.setIndeterminate(true);
                            progress.add(bar);
                            progress.pack();
                            progress.setVisible(true);
                            loadConfig(config);
                            progress.dispose();
                            setEnabledTabs(true);
                        }
                    }.start();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    loadXML.setBounds(670, 20, 120, 20);
    p8.add(loadXML);
    //         if(!PermissionValidator.canChangeFWM()){
    //             loadXML.setEnabled(false);
    //         }

    tdbfile = new JTextField();
    addPanel("Database XML path", "File location for database configuration", tdbfile,
            RunnerRepository.REMOTEDATABASECONFIGPATH + RunnerRepository.REMOTEDATABASECONFIGFILE, 375, true,
            null);
    temailfile = new JTextField();
    //         emailpanel = (JPanel)
    addPanel("Email XML path", "File location for email configuration", temailfile,
            RunnerRepository.REMOTEEMAILCONFIGPATH + RunnerRepository.REMOTEEMAILCONFIGFILE, 448, true, null)
                    .getParent();
    //paths.remove(emailpanel);

    //         emailpanel.setBounds(360,440,350,100);
    //         RunnerRepository.window.mainpanel.p4.getEmails().add(emailpanel);

    tglobalsfile = new JTextField();
    addPanel("Globals XML file", "File location for globals parameters", tglobalsfile,
            RunnerRepository.GLOBALSREMOTEFILE, 521, true, null);

    tceport = new JTextField();
    addPanel("Central Engine Port", "Central Engine port", tceport, RunnerRepository.getCentralEnginePort(),
            1003, false, null);
    //         traPort = new JTextField();
    //         addPanel("Resource Allocator Port","Resource Allocator Port",
    //                 traPort,RunnerRepository.getResourceAllocatorPort(),808,false,null);                
    //         thttpPort = new JTextField();
    //         addPanel("HTTP Server Port","HTTP Server Port",thttpPort,
    //                 RunnerRepository.getHTTPServerPort(),740,false,null);

    //paths.add(loadXML);

    if (!PermissionValidator.canChangeFWM()) {
        ttcpath.setEnabled(false);
        tMasterXML.setEnabled(false);
        tUsers.setEnabled(false);
        tepid.setEnabled(false);
        tSuites.setEnabled(false);
        tlog.setEnabled(false);
        trunning.setEnabled(false);
        tdebug.setEnabled(false);
        tsummary.setEnabled(false);
        tinfo.setEnabled(false);
        tcli.setEnabled(false);
        tdbfile.setEnabled(false);
        temailfile.setEnabled(false);
        tceport.setEnabled(false);
        libpath.setEnabled(false);
        tsecondarylog.setEnabled(false);
        testconfigpath.setEnabled(false);
        tglobalsfile.setEnabled(false);
        logsenabled.setEnabled(false);
    }

}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JButton getCancelBtn(final JFrame d) {
    JButton cancelar = new JButton("Cancelar", LogicConstants.getIcon("button_cancel"));
    cancelar.addActionListener(new ActionListener() {

        @Override/*from  w  ww .  j  a v a  2 s .  c  o m*/
        public void actionPerformed(ActionEvent e) {

            if (cambios) {
                int res = JOptionPane.showConfirmDialog(d,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION);
                if (res != JOptionPane.CANCEL_OPTION) {
                    d.dispose();
                }
            } else {
                d.dispose();
            }
        }
    });
    return cancelar;
}