2011年8月2日 星期二

WindowBuilder 製作的 gui


import java.awt.EventQueue;

import javax.swing.JFrame;
import java.awt.FlowLayout;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import javax.swing.JButton;


public class Test1 {

    private JFrame frame;
    private JTextField textField;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Test1 window = new Test1();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
    }

    /**
     * Create the application.
     */
    public Test1() {
initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 500, 388);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

textField = new JTextField();
frame.getContentPane().add(textField);
textField.setColumns(10);

JButton btnNewButton = new JButton("連線");
frame.getContentPane().add(btnNewButton);
    }

}

沒有留言:

張貼留言