cn.p1.swing.JFramDemo.JFrameDemo.java Source code

Java tutorial

Introduction

Here is the source code for cn.p1.swing.JFramDemo.JFrameDemo.java

Source

package cn.p1.swing.JFramDemo;

import com.jgoodies.forms.layout.CellConstraints;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class JFrameDemo extends javax.swing.JFrame {

    {
        //Set Look & Feel
        try {
            javax.swing.UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private JButton jButton1;

    /**
    * Auto-generated main method to display this JFrame
    */
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrameDemo inst = new JFrameDemo();
                inst.setLocationRelativeTo(null);
                inst.setVisible(true);
            }
        });
    }

    public JFrameDemo() {
        super();
        initGUI();
    }

    private void initGUI() {
        try {
            getContentPane().setLayout(null);
            setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            {
                jButton1 = new JButton();
                new FlowLayout();
                jButton1.setLayout(null);
                getContentPane().add(jButton1, new CellConstraints("4, 4, 1, 1, default, default"));
                jButton1.setText("\u6309\u94ae");
                jButton1.setBounds(141, 104, 94, 34);
                jButton1.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jButton1ActionPerformed(evt);
                    }
                });
            }
            pack();
            setSize(400, 300);
        } catch (Exception e) {
            //add your error handling code here
            e.printStackTrace();
        }
    }

    private void jButton1ActionPerformed(ActionEvent evt) {
        //      System.out.println("jButton1.actionPerformed, event="+evt);
        //TODO add your code for jButton1.actionPerformed
        System.exit(0);
    }

}