画板问题
如何是画板上的控件随着窗口的最大画而变大
2010-05-19 11:55
程序代码:import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyFieldExample extends JFrame implements ActionListener
{
JLabel JL1,JL2,JL3;
JButton JB1,JB2;
JTextField JF1;
JPasswordField JP1;
public MyFieldExample()
{
super("登录界面");
JL1=new JLabel("用户名称");
JL1.setBounds(15,5,60,20);
JL2=new JLabel("登录密码");
JL2.setBounds(15,25,60,20);
JF1=new JTextField("",20);
JF1.setBounds(110,5,100,20);
JP1=new JPasswordField("",20);
JP1.setBounds(110,25,100,20);
JB1=new JButton("确定");
JB1.setBounds(35,50,60,30);
JB1.addActionListener(this);
JB2=new JButton("取消");
JB2.setBounds(130,50,60,30);
JB2.addActionListener(this);
JL3=new JLabel("");
JL3.setBounds(60,90,200,30);
Container winContainer=this.getContentPane();
winContainer.setLayout(null);
winContainer.add(JL1);
winContainer.add(JL2);
winContainer.add(JB1);
winContainer.add(JB2);
winContainer.add(JL3);
winContainer.add(JF1);
winContainer.add(JP1);
this.setSize(250,150);
this.setVisible(true);
}
public static void main(String args[])
{
MyFieldExample w1=new MyFieldExample();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==JB1)
{
if(JF1.getText().equals("JAVA")&&JP1.getText().equals("1234"))
JL3.setText("输入正确,登录成功");
else
JL3.setText("输入错误,请重新输入");
}
else if
(e.getSource()==JB2)
System.exit(0);
}
}
帮忙看看,看怎么能最大化的时候,控件也跟着变换
2010-05-19 15:11
2010-05-19 16:49