注册 登录
编程论坛 J2EE论坛

求大神看下,是哪里错了!

浩淼 发布于 2014-04-10 15:23, 2118 次点击
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextField;
import java.awt.Color;
class f1 extends JFrame
{
 f1()
{
   super("这是我做的东西");
   JButton b1=new JButton("发挥好");
   JTextField b2=new JTextField(15);
   b1.setForeground(Color.red);
   setLayout(new FlowLayout(FlowLayout.LEFT));
   add(b1);add(b2,BorderLayout.NORTH);
   

 }
}
public class ks1
{
   public static void main(String[] args)
   {
     f1 f=new f1();
     f.setSize(200,300);//设置框架大小
     f.setLocation(400,200);//location定位
     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     f.setVisible(true);//放T显示,放F不显示
    }
}
1 回复
#2
我爱敲代码2014-04-12 23:32
f1()
{
   super("这是我做的东西");
   JButton b1=new JButton("发挥好");
   JTextField b2=new JTextField(15);
   b1.setForeground(Color.red);
   setLayout(new BorderLayout());//卡片布局,FlowLayout是流布局
   add(b1);add(b2,BorderLayout.NORTH);
   

}
1