Example usage for javax.swing WindowConstants DISPOSE_ON_CLOSE

List of usage examples for javax.swing WindowConstants DISPOSE_ON_CLOSE

Introduction

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

Prototype

int DISPOSE_ON_CLOSE

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

Click Source Link

Document

The dispose-window default window close operation.

Usage

From source file:WindowEventHandler.java

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

    JLabel label = new JLabel("This is a Swing frame", JLabel.CENTER);

    frame.add(label);/*from  www.  j  av  a 2 s. com*/

    frame.addWindowListener(new WindowEventHandler());
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setSize(350, 200); // width=350, height=200
    frame.setVisible(true); // Display the frame
}

From source file:Main.java

public static void main(String[] args) {

    JFrame f = new JFrame();
    f.setTitle("Example2");
    f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JPanel p1 = new JPanel(new FlowLayout(FlowLayout.CENTER));
    p1.setBorder(new TitledBorder(new LineBorder(Color.BLACK), "JPanel 1"));
    for (int i = 0; i < NB1; i++)
        p1.add(new JButton("Button " + i));

    JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER));

    p2.setBorder(new TitledBorder(new LineBorder(Color.BLACK), "JPanel 2"));
    for (int i = NB1; i < NB2; i++)
        p2.add(new JButton("Button " + i));

    JPanel p3 = new JPanel(new FlowLayout(FlowLayout.CENTER));
    p3.setBorder(new TitledBorder(new LineBorder(Color.BLACK), "JPanel 3"));
    for (int i = NB2; i < NB3; i++)
        p3.add(new JButton("Button " + i));

    JPanel global = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL; // added
    gbc.weightx = 1.0f; // added
    gbc.gridy = 0;/*from   w  w  w .  j ava  2  s  .c  o m*/
    global.add(p1, gbc);
    gbc.gridy++;
    global.add(p2, gbc);
    gbc.gridy++;
    global.add(p3, gbc);

    f.add(global);
    f.pack();
    f.setVisible(true);

}

From source file:com.petersoft.advancedswing.enhancedtextarea.EnhancedTextArea.java

/**
 * Auto-generated main method to display this JPanel inside a new JFrame.
 *//*w  w w.j a  v  a 2 s .c  om*/
public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.getContentPane().add(new EnhancedTextArea());
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

From source file:UIDefaultsTreeModel.java

public static void main(String[] args) {
    JFrame treeFrame1 = new JFrame();

    JScrollPane jScrollPane1 = new JScrollPane();
    JTree jTree1 = new JTree(new UIDefaultsTreeModel());

    treeFrame1.setSize(new Dimension(400, 300));
    treeFrame1.addWindowListener(new WindowAdapter() {
        public void windowClosed(WindowEvent e) {
            System.exit(0);/*w  w  w .  jav a  2 s.  co  m*/
        }
    });
    treeFrame1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    treeFrame1.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
    jScrollPane1.getViewport().add(jTree1, null);

    treeFrame1.setVisible(true);
}

From source file:net.sf.jhylafax.addressbook.AddressBook.java

/**
 * @param args/*  www  . j av  a 2 s . c om*/
 */
public static void main(String[] args) {
    final AddressBook app = new AddressBook();
    app.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    app.restoreLayout(new SettingStore(Settings.backstore));

    try {
        File file = JHylaFAX.getAddressBookFile();
        if (file.exists()) {
            app.load(file);
        }
    } catch (Exception e) {
        ErrorDialog.showError(null, i18n.tr("Could not load address book"), i18n.tr("JHylaFAX Error"), e);
    }

    app.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            try {
                File file = JHylaFAX.getAddressBookFile();
                app.store(file);
            } catch (Exception e) {
                ErrorDialog.showError(null, i18n.tr("Could not store address book"), i18n.tr("JHylaFAX Error"),
                        e);
            }
        }
    });

    app.setVisible(true);
}

From source file:gda.images.GUI.CmuCameraDisplayPanel.java

/**
 * @param args/*www. j av  a  2 s . com*/
 */
public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame();
    frame.setSize(1024, 768);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    CmuCameraDisplayPanel cmu = new CmuCameraDisplayPanel();

    RTPStreamReceiver receiver = new RTPStreamReceiver();
    receiver.setHost("224.120.120.120");
    receiver.setPort(22224);
    receiver.addImageListener(cmu);
    receiver.configure();

    cmu.setVideoReceiver(receiver);

    cmu.configure();
    frame.add(cmu);
    frame.setVisible(true);
}

From source file:gda.gui.BatonPanel.java

/**
 * Auto-generated main method to display this JPanel inside a new JFrame.
 * //from  ww w.  j av a2s . c  o m
 * @param args
 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.pack();
    frame.setSize(792, 419);
    frame.setPreferredSize(new java.awt.Dimension(792, 419));
    frame.setVisible(true);
    {
        batonPanel_IL = new BatonPanel();
        frame.getContentPane().add(batonPanel_IL, BorderLayout.CENTER);
        BorderLayout batonPanel_ILLayout = new BorderLayout();
        batonPanel_IL.setLayout(batonPanel_ILLayout);
    }
}

From source file:com.game.ui.views.PlayerEditor.java

public static void main(String[] args) {
    try {//from  w w  w. ja v a 2  s  .  c o  m
        GameBean.doInit();
        if (GameBean.weaponDetails.size() > 0) {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            frame.add(new PlayerEditor());
            frame.setName("Frame");
            frame.pack();
            frame.setVisible(true);
        }
    } catch (Exception ex) {
        Logger.getLogger(PlayerEditor.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Main.java

static public void show(Component panel) {
    JFrame frame = new JFrame();
    frame.setTitle("TestForm");
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.getContentPane().add(panel);//from  w ww .  j  a  v  a 2  s  .co  m
    frame.pack();
    frame.show();
}

From source file:Main.java

private static JDialog dialogRaw(String title, final Window frame, ModalityType modal) {
    final JDialog dialog = new JDialog(frame, modal);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setTitle(title);//w w  w .  j  av  a2s . co  m
    return dialog;
}