Example usage for javax.swing WindowConstants EXIT_ON_CLOSE

List of usage examples for javax.swing WindowConstants EXIT_ON_CLOSE

Introduction

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

Prototype

int EXIT_ON_CLOSE

To view the source code for javax.swing WindowConstants EXIT_ON_CLOSE.

Click Source Link

Document

The exit application default window close operation.

Usage

From source file:Main.java

public Main() {
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    jComboBox1 = new JComboBox();
    jComboBox1.setModel(new DefaultComboBoxModel(new String[] { "1", "2" }));
    jComboBox1.addItemListener(evt -> {
        if (jComboBox1.isPopupVisible()) {
            jComboBox1.setPopupVisible(false);
            fireTask(evt);/*from w  w w  . j  ava  2 s  . c om*/
        }
    });
    add(jComboBox1);
    pack();
}

From source file:Main.java

public Main() {
    super();//from  w ww.  j a v  a 2  s.com
    this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    Container contentPane = this.getContentPane();
    textArea = new JTextArea();
    JScrollPane pane = new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    contentPane.add(pane, BorderLayout.CENTER);
}

From source file:Main.java

public Main() {
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    jList1.setModel(new AbstractListModel() {
        String[] strings = { "Computer", "Mouse", "HDD" };

        public int getSize() {
            return strings.length;
        }/*from   w w w  . ja v  a2s  .c  om*/

        public Object getElementAt(int i) {
            return strings[i];
        }
    });
    jList1.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            jList1ValueChanged(evt);
        }
    });
    jTextField2.setText("jTextField1");
    jPanel1.add(new JScrollPane(jList1));
    jPanel1.add(jTextField2);
    frame.add(jPanel1);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public Main(String title) {
    super(title);
    this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    Container contentPane = this.getContentPane();
    ButtonGroup group = new ButtonGroup();
    small = new JRadioButton("small");
    medium = new JRadioButton("medium");
    large = new JRadioButton("large");

    group.add(small);//from  w  w w.  j  av a2 s  . c  o m
    group.add(medium);
    group.add(large);
    button = new JButton("Click here.");
    button.setBounds(100, 50, 100, 50);
    JPanel center = new JPanel();
    center.setLayout(null);
    center.add(button);
    contentPane.add(center, BorderLayout.CENTER);

    JPanel north = new JPanel();
    north.add(small);
    north.add(medium);
    north.add(large);
    contentPane.add(north, BorderLayout.NORTH);

    ChangeSize listener = new ChangeSize(button);
    small.addItemListener(listener);
    medium.addItemListener(listener);
    large.addItemListener(listener);
}

From source file:Main.java

public Main() {
    panel.setLayout(new GridBagLayout());
    panel.add(subscribe);// w  w  w.  ja  v  a  2s . co m
    panel.add(unsubscribe);
    panel.add(refresh);
    panel.add(save);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.add(panel);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setSize(400, 300);//from   w w w . j a  va  2s  . c  o m
    jPopupMenu1.add(jMenuItem1);
    jTabbedPane1.addTab(null, jLabel1);
    jTabbedPane1.addTab(null, jLabel2);
    getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
    int tabCount = jTabbedPane1.getTabCount();
    for (int i = 0; i < tabCount; i++) {
        JLabel jLabel = new JLabel("Testing the tab" + (i + 1));
        jTabbedPane1.setTabComponentAt(i, jLabel);
        jLabel.setName(String.valueOf(i));
        jLabel.setComponentPopupMenu(jPopupMenu1);
    }
    jPopupMenu1.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuCanceled(final PopupMenuEvent evt) {
        }

        @Override
        public void popupMenuWillBecomeInvisible(final PopupMenuEvent evt) {
        }

        @Override
        public void popupMenuWillBecomeVisible(final PopupMenuEvent evt) {
            JPopupMenu source = (JPopupMenu) evt.getSource();
            JLabel invoker = (JLabel) source.getInvoker();
            JLabel component = (JLabel) jTabbedPane1.getComponentAt(Integer.parseInt(invoker.getName()));
            jMenuItem1.setText(invoker.getText() + ":  " + component.getText());
        }
    });
}

From source file:Main.java

public Main() {
    setSize(500, 500);//from   w  ww  . ja v a2  s  .  c o m
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setLayout(new GridLayout(0, 1));
    JPanel buttonPanel = new JPanel();

    JButton addButton = new JButton("add");
    addButton.addActionListener(e -> addElementToArrayList());
    JButton removeButton = new JButton("remove");
    removeButton.addActionListener(e -> removeElementFromArrayList());

    tabbedPane = new JTabbedPane();
    tabbedPaneMouseListener = (new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
                if (e.getClickCount() == 1) {
                    System.out.println("Do Something");
                }
            }
        }
    });
    tabbedPane.addMouseListener(tabbedPaneMouseListener);

    buttonPanel.add(addButton);
    buttonPanel.add(removeButton);
    add(buttonPanel);
    this.add(tabbedPane);
}

From source file:FreeMemoryViewer.java

public FreeMemoryViewer(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    setSize(500, 270);//from w ww . j  a  v  a2  s . com
    setVisible(true);
    setFocusable(true);
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset, chartTitle);
    ChartPanel chartPanel = new ChartPanel(chart);
    setContentPane(chartPanel);
    pack();
    updateChart();
}

From source file:arlocros.Imshow.java

/**
 * @param opencvImage//from  ww w .  j  av  a  2 s.  c o m
 */
public static void show(Mat opencvImage) {

    Dimension frameSize = new Dimension(opencvImage.rows(), opencvImage.cols());
    if (frame == null) {
        frame = new Imshow("", frameSize.height, frameSize.width);
        frame.Window.setVisible(true);

        frame.Window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        if (frame.SizeCustom) {
            Imgproc.resize(opencvImage, opencvImage, new Size(frame.Height, frame.Width));
        }
    }
    BufferedImage bufImage = null;
    try {

        int type = BufferedImage.TYPE_BYTE_GRAY;
        if (opencvImage.channels() > 1) {
            type = BufferedImage.TYPE_3BYTE_BGR;
        }
        int bufferSize = opencvImage.channels() * opencvImage.cols() * opencvImage.rows();
        byte[] b = new byte[bufferSize];
        opencvImage.get(0, 0, b);
        BufferedImage bufferedImage = new BufferedImage(opencvImage.cols(), opencvImage.rows(), type);
        final byte[] targetPixels = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
        System.arraycopy(b, 0, targetPixels, 0, b.length);
        bufImage = bufferedImage;
        frame.image.setImage(bufImage);
        frame.Window.pack();
        frame.label.updateUI();
        //frame.Window.setVisible(true);
    } catch (RuntimeException e) {
        logger.info("Exception while visualizing.", e);
    }
}

From source file:BrowserAverage.java

public BrowserAverage(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    setSize(500, 270);//  w ww.ja  v a 2s .  c  om
    setVisible(true);
    setFocusable(true);
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    moarspeed = new JButton("MOAR");

    PieDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset, chartTitle);
    ChartPanel chartPanel = new ChartPanel(chart);

    JPanel panel1 = new JPanel();
    panel1.add(chartPanel);
    JPanel panel2 = new JPanel();
    panel2.add(moarspeed);
    JPanel container = new JPanel();
    container.add(panel1);
    container.add(panel2);
    getContentPane().add(container);

    moarspeed.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rotator.setSpeed(rotator.getSpeed() + 1);
        }
    });

    pack();
}