这段代码有什么问题啊~怎么不可以显示(JAVA的)

来源:百度知道 编辑:UC知道 时间:2024/05/22 08:35:34
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class IllegalAgeException extends Exception
{
public String getMessage()
{
return "Invalid Age. The customer should not be provided with a connection";
}
}
public class yy extends JApplet
{
int custAge;
JPanel pl;
JButton bb;
JLabel ll;
JTextField tt;
FlowLayout ff;

void setAge(int age) throws IllegalAgeException
{
if((age<20)||(age>60)) throw new IllegalAgeException();
custAge=age;
}
public void init()
{
ff=new FlowLayout(FlowLayout);
pl=new JPanel();
getContentPane().add(pl);
//pl=(JPanel)getContentPane();
pl.setLayout(ff);
ll=new JLabel("Enter Customer Age:");
tt=new JTextField(5);
bb=new JButton("ss");
pl.add(ll);
pl.add(tt);
pl.add(bb);
ValidateAct

好象没java的开始捏???

看了一点,没看太懂,程序有点乱,既然你写applet为什么不把组成部分写完整呢,JPanel本来默认就是FlowLayout,何必费神重申一遍?再说了,我记得FlowLayout也没FlowLayout参数啊,参数必须是FlowLayout.LEFT、FlowLayout.RIGHT、FlowLayout.CENTER、FlowLayout.LEADING 或 FlowLayout.TRAILING。