本帖最后由 睡不够的猪 于 2013-11-12 21:39 编辑
不知道为什么 我这个Button组件显示不出来,请大神帮忙!- //这个Button组件显示不出来,不知道为什么。。。
- import java.awt.Button;
- import java.awt.Choice;
- import java.awt.FlowLayout;
- import java.awt.Frame;
- import java.awt.GridBagLayout;
- import java.awt.GridLayout;
- import java.awt.Label;
- import java.awt.Panel;
- import java.awt.TextArea;
- import java.awt.TextField;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- public class GUITest1 {
- public static void main(String[] args) {
-
- Frame frame = new Frame();
- frame.setBounds(300,200,700, 450);
- frame.setLayout(null);
- Panel panel1 = new Panel();
- panel1.setSize(700, 350);
- Panel panel2 = new Panel();
- panel2.setSize(700, 100);
- frame.add(panel1);
- frame.add(panel2);
- //往panel2中加入Button组件
- panel2.setLayout(null);
- Button button = new Button("提交");
- button.setSize(200, 20);
- panel2.add(button);
-
- frame.setVisible(true);
-
- frame.addWindowListener(new WindowAdapter(){
- public void windowClosing(WindowEvent e){
- System.exit(0);
- }
- });
-
- }
- }
复制代码 |