我正在尝试连接我的 java 文件,这样我就可以创建一个使用主菜单的应用程序,但无论我做什么,这个错误总是持续存在。这是我的代码:Zakat.java
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Zakat extends MIDlet
{
private Display display;
public FormLoading FormLoading;
public Keluar Keluar;
public MenuUtama MenuUtama;
public Pengenalan Pengenalan;
public Kalkulator Kalkulator;
public About About;
public Profil Profil;
//public CanvasAwal canvasAwal;
public Zakat()
{
display = Display.getDisplay(this);
FormLoading = new FormLoading(this);
Keluar = new Keluar(this);
MenuUtama = new MenuUtama(this);
Pengenalan = new Pengenalan(this);
Kalkulator = new Kalkulator(this);
About = new About(this);
Profil = new Profil(this);
//canvasAwal = new CanvasAwal(this);
}
public void startApp()
{
Display.getDisplay(this).setCurrent(FormLoading);
}
public void pauseApp()
{
}
public void destroyApp(boolean b)
{
}
}
MenuUtama.java
import java.io.IOException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
class MenuUtama extends List implements CommandListener
{
public Zakat app;
Ticker tc;
public MenuUtama(Zakat app)
{
super("Menu Utama",List.IMPLICIT);
this.app = app;
Image img=null;
Image img1=null;
Image img2=null;
try
{
img = Image.createImage("/icon1.png");
}
catch(Exception e)
{
}
append("Pengenalan Zakat",img);
append("Kalkulator",img);
append("About",img);
append("Profil",img);
append("Keluar",img);
addCommand(new Command("Pilih",Command.OK,0));
addCommand(new Command("Keluar",Command.EXIT,0));
tc = new Ticker ("Silahkan Pilih");
setTicker(tc);
setCommandListener(this);
}
public void commandAction (Command c, Displayable d)
{
switch(getSelectedIndex())
{
case 0:
Display.getDisplay(app).setCurrent(app.Pengenalan);
break;
case 1:
Display.getDisplay(app).setCurrent(app.Kalkulator);
break;
case 2:
Display.getDisplay(app).setCurrent(app.About);
break;
case 3:
Display.getDisplay(app).setCurrent(app.Profil);
break;
case 4:
Display.getDisplay(app).setCurrent(app.Keluar);
break;
}
switch( c.getCommandType())
{
case Command.EXIT:
Display.getDisplay(app).setCurrent(app.Keluar);
break;
}
}
}
Kalkulator.java
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.IOException;
public class Kalkulator extends MIDlet implements CommandListener,ItemCommandListener
{
Zakat app;
private Command cmdHitung = new Command("Hitung",Command.ITEM,1);
private Command exitCommand = new Command("Kembali",Command.EXIT,1);
private Display display;
private Form form = new Form("kalkulator");
private TextField var;
private TextField hasil;
public Kalkulator(Zakat app)
{
var = new TextField("Penghasilan selama 1 Tahun",null,12,TextField.NUMERIC);
hasil = new TextField("Zakat yang harus dibayarkan",null, 12 ,TextField.NUMERIC);
form.append(var);
form.append(hasil);
form.setCommandListener(this);
}
public void startApp()
{
if(display==null)
{
display = Display.getDisplay(this);
display.setCurrent(form);
}
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction (Command c, Displayable d)
{
switch (c.getCommandType())
{
case Command.EXIT:
Display.getDisplay(app).setCurrent(app.MenuUtama);
break;
}
}
public void commandAction(Command c, Item item)
{
if(c.equals(this.cmdHitung))
{
int hsl = Integer.parseInt(var.getString()) / 40;
hasil.setString(Integer.toString(hsl));
}
}
}
请帮助,并感谢之前。