1.如何一次性的创建多个对象?并且输出?是不是要用for循环?还是for each遍历?或者是其他方法?
2.对象数组是怎么用的呢?你能不能详细介绍一下啊?最好详细点,越详细越好!请大神们不惜赐教,谢谢了!
------解决方案--------------------
- Java code
import java.awt.*;import javax.swing.*;public class B extends JFrame{ private JTextField jt1; private JLabel jl1,jl2,jl3; private JPasswordField mima; private JButton jb1,jb2; private JPanel jp1=new JPanel(); private JPanel jp2=new JPanel(); private JPanel jp3=new JPanel(); private BorderLayout bb=new BorderLayout(); public B(){ super("qq2010"); this.setLayout(bb); jl1=new JLabel("用户名:"); jl2=new JLabel("密码:"); mima=new JPasswordField (10); jt1=new JTextField(10); jb1=new JButton("注册"); jb2=new JButton("登陆"); jp1.add(jl1); jp1.add(jt1); jp1.add(jl2); jp1.add(mima); jp2.add(jb1); jp2.add(jb2); jl3=new JLabel("img"); add(jl3,BorderLayout.NORTH); add(jp1,BorderLayout.CENTER); add(jp2,BorderLayout.SOUTH); this.setSize(200,200); this.setVisible(true); } public static void main(String[] args){ B b=new B(); b.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }}