例子..
/*
* Main.java
*
* Created on 2007年7月29日, 下午10:49
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
//package nb;
/**
*
* @author Administrator
*/
public class Main extends JPanel{
/**
* @param args the command line arguments
*/
private JButton jb1,jb2;
public Main(){
setLayout(null);
jb1=new JButton("button1");
jb1.setBounds(10,10,50,50);
add(jb1);
jb2=new JButton("button2");
jb2.setBounds(70,30,50,50);
add(jb2);
}
public static void main(String[] args) {
JFrame frame=new JFrame("test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new Main());
frame.setSize(300,300);
frame.setVisible(true);
}
}