我正在創建一個小程序,發生的所有事情是它會打開顯示「有多少流派?然後出現一個textField。我輸入一個數字,然後回車,但沒有任何事情發生! (我沒有得到任何錯誤,但沒有任何反應)試圖創建一個簡單的小程序,但它不會貫穿整個程序
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(){
}}
*「試圖創建一個簡單的小程序..」*「簡單的小程序」是一個重言式。有關詳細信息,請參閱[爲什麼CS教師應停止教授小程序?](http://programmers.stackexchange.com/questions/196499/why-should-cs-teachers-stop-teaching-applets)。如果你想'簡單',編碼一個基於Swing的框架。 – 2013-05-02 04:11:53