Example usage for javax.swing JFrame setDefaultCloseOperation

List of usage examples for javax.swing JFrame setDefaultCloseOperation

Introduction

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

Prototype

@BeanProperty(preferred = true, enumerationValues = { "WindowConstants.DO_NOTHING_ON_CLOSE",
        "WindowConstants.HIDE_ON_CLOSE", "WindowConstants.DISPOSE_ON_CLOSE",
        "WindowConstants.EXIT_ON_CLOSE" }, description = "The frame's default close operation.")
public void setDefaultCloseOperation(int operation) 

Source Link

Document

Sets the operation that will happen by default when the user initiates a "close" on this frame.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(600, 400);//from ww w  .ja  va 2 s .co  m
    frame.setVisible(true);
    Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> {
        System.out.println(frame.getLocation());
    }, 0, 1000, TimeUnit.MILLISECONDS);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.add(new JSeparator(JSeparator.VERTICAL));

    frame.setSize(300, 200);//from ww  w.j  a  v a  2  s .  c  om
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JScrollBar oneJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    frame.add(oneJScrollBar, BorderLayout.NORTH);
    frame.setSize(200, 44);//from   w w  w.j a  v a  2s. c  om
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("<html>bold <br> plain</html>");
    frame.add(label);//from  ww w .  j  a  v a2  s  .  c  om

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTree tree = new JTree();
    for (int i = 0; i < tree.getRowCount(); i++) {
        tree.expandRow(i);//from   w w  w  .ja  va2s .com
    }
    f.add(new JScrollPane(tree));
    f.pack();
    f.setSize(200, 200);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(getPanel());/*from   w  w w .jav  a  2 s  .c  o m*/
    f.pack();
    f.setVisible(true);
}

From source file:MyCanvas.java

public static void main(String[] a) {
    JFrame window = new JFrame();
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.setBounds(30, 30, 300, 300);//from  ww  w . ja v a 2s.c  om
    window.getContentPane().add(new MyCanvas());
    window.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JCheckBox checkBox = new JCheckBox("A");

    checkBox.setToolTipText("Italic font");

    frame.add(checkBox, BorderLayout.NORTH);
    frame.setSize(300, 100);//from  ww w .  java 2  s .  c o m
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) {
    JFrame frame = new MainClass();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.pack();//from ww  w. j  a v a  2 s .co m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Swing");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Set the x, y, width and height properties
    frame.setBounds(50, 50, 200, 200);// w w w  .  jav  a2  s. com

    frame.setVisible(true);
}