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:DynamicUtilTreeNodeDemo.java

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

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
    Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
    hashtable.put("Two", new String[] { "A", "B", "C" });

    Hashtable<Object, Object> innerHashtable = new Hashtable<Object, Object>();

    innerHashtable.put("Two", new String[] { "A", "B", "C" });

    hashtable.put("Three", innerHashtable);
    JTree.DynamicUtilTreeNode.createChildren(root, hashtable);
    JTree tree = new JTree(root);

    JScrollPane scrollPane = new JScrollPane(tree);
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);//from  w w w .j  a va 2 s .c o m
    frame.setVisible(true);

}

From source file:AddingToJScrollPane.java

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

    JLabel label = new JLabel("Label");
    label.setPreferredSize(new Dimension(1000, 1000));
    JScrollPane jScrollPane = new JScrollPane(label);

    frame.add(jScrollPane, BorderLayout.CENTER);
    frame.setSize(400, 150);/*from  ww w .  j  a  v a2 s .c  om*/
    frame.setVisible(true);
}

From source file:Main.java

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

    JFileChooser fileChooser = new JFileChooser(".");

    String text = fileChooser.getApproveButtonToolTipText();

    frame.add(fileChooser, BorderLayout.CENTER);

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

From source file:Main.java

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

    JFileChooser fileChooser = new JFileChooser(".");

    String text = fileChooser.getApproveButtonText();

    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();//from  w  w  w  . j  a  va  2s . com
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new MyContentPane());
    frame.pack();/*ww w . j  av  a  2s  . c  om*/
    frame.setLocationByPlatform(true);
    frame.setVisible(true);
}

From source file:Main.java

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

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(3, 0));

    for (int i = 1; i <= 9; i++) {
        buttonPanel.add(new JButton("Button  " + i));
    }//from w w w. j  a va2s  .  c  o m

    contentPane.add(buttonPanel, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

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

    JFileChooser fileChooser = new JFileChooser(".");

    int mu = fileChooser.getApproveButtonMnemonic();

    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();// w  w  w  . j a va  2  s .  com
    frame.setVisible(true);
}

From source file:Main.java

License:asdf

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

    JEditorPane editorPane = new JEditorPane();
    editorPane.setText("asdf");

    JScrollPane scrollPane = new JScrollPane(editorPane);
    frame.add(scrollPane);//from   w w w  . j a  v  a  2  s  .  com

    frame.setSize(640, 480);
    frame.setVisible(true);
}

From source file:BallRoom.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(200, 300);//w  w w.  j a v a 2s .  c o m
    PaintSurface canvas = new PaintSurface();

    ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(3);
    executor.scheduleAtFixedRate(canvas, 0L, 100L, TimeUnit.MILLISECONDS);

    f.getContentPane().add(canvas);
    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(new TestPane());
    frame.setSize(100, 100);//w w w  . j  a  va2 s.com
    frame.setVisible(true);
}