- /*
- * NewJFrame.java
- *
- * Created on 2008年8月23日, 下午2:52
- */
- package gui;
- import javax.swing.JOptionPane;
- /**
- *
- * @author Administrator
- */
- public class NewJFrame extends javax.swing.JFrame {
- /** Creates new form NewJFrame */
- public NewJFrame() {
- initComponents();
- }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jTextField1 = new javax.swing.JTextField();
- setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
- setTitle("关闭窗体测试");
- setResizable(false);
- addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent evt) {
- formWindowClosing(evt);
- }
- });
- jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
- jTextField1.setText("请点击关闭按钮");
- jTextField1.setAutoscrolls(false);
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap(125, Short.MAX_VALUE)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(122, 122, 122))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap(113, Short.MAX_VALUE)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(113, 113, 113))
- );
- pack();
- java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
- java.awt.Dimension dialogSize = getSize();
- setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
- }// </editor-fold>
- private void formWindowClosing(java.awt.event.WindowEvent evt) {
- if (JOptionPane.showConfirmDialog(this, "真的要关闭吗?", "请确认", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
- System.exit(0);
- }
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new NewJFrame().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JTextField jTextField1;
- // End of variables declaration
- }