代码如下
import javax.swing.*;
import java.awt.*;
public class realizeclass {
public static void main(String[] args) {
wild yy=new wild();
yy.setSize(400,300);
yy.setVisible(true);
yy.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// TODO Auto-generated method stub
}
}
class wild extends JFrame{
public wild() {
super("基本信息");
JLabel one= new JLabel("姓名");
JLabel two= new JLabel("密码");
JLabel three=new JLabel("简介");
JPasswordField code=new JPasswordField(30);
JTextField first=new JTextField(30);
JTextArea sth=new JTextArea(10,30);
JScrollPane roll=new JScrollPane(sth);
getContentPane().add(one);
getContentPane().add(first);
getContentPane().add(two);
getContentPane().add(code);
getContentPane().add(three);
getContentPane().add(roll);
}
}
程序运行结果如下
我创建了文本框 标签 等多个对象组件,为什么最终运行结果只有文本域组件