我正在创建一个小程序,所发生的只是它打开显示“有多少类型?” 然后出现一个文本字段。我输入一个数字并按回车,但没有任何反应!(我没有收到任何错误,但没有任何反应)
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class appletPracticw extends Applet implements ActionListener {
TextField numG;
TextField g ;
TextField numS;
TextField sog;
private int number;
private int numberOfSongs;
String gener;
String songName;
public void go(){
numG= new TextField(5);
numS= new TextField(5);
g= new TextField(5);
sog= new TextField(5);
numG.addActionListener(this);
g.addActionListener(this);
sog.addActionListener(this);
numS.addActionListener(this);
Tracker t=new Tracker();
add(new Label("How many genres are there? ")); add(numG);
for(int i=0;i<number;i++){
catogories c=new catogories();
add(new Label("Name of genere: ")); add(g);
t.addCatogory(c,gener);
}
for(int x=0;x<number;x++){
add(new Label("How many songs are there in "+t.getCatogories().get(x).getGenere())); add(numS);
for(int i=0;i<numberOfSongs;i++){
Songs s=new Songs();
add(new Label("The name of song "+(i+1)+" is")); add(sog);
t.getCatogories().get(x).addSong(s, songName);
}
}
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==numG){
String num=numG.getText();
number=Integer.parseInt(num);
}
if(e.getSource()==numS){
String num=numS.getText();
numberOfSongs=Integer.parseInt(num);
}
if(e.getSource()==g){
gener=g.getText();
}
if(e.getSource()==sog){
songName=sog.getText();
}
}
public void init() {
go();
} 公共 appletPracticw() {
} }