JAVA图形界面 为什么只能显示面板和窗口,不能显示按钮等控件?
package chap01;import javax.swing.*;
import java.awt.*;
class A{
public A(){
JFrame frame = new JFrame("界面");
frame.setVisible(true);
frame.setSize(200,400);
JPanel panel = new JPanel();
panel.setBackground(Color.white);
frame.add(panel);
JTextField field = new JTextField("zhangqi",15);
panel.add(field);
JButton bu = new JButton("按钮");
panel.add(bu);
}
}
public class TF {
public static void main(String[] args) {
new A();
}
}