当我运行我的代码时,我会在左下角看到一个小程序窗口,其中显示“Start:applet not initialized”。我实际上没有安装JRE,但得到了离线安装程序并指定它在“eclipse.ini”中的位置,这可能是个问题吗?下面是我的代码和我在applet和控制台中得到的错误。
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class SpMain extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
JButton define, conjugate, close;
SpMain(String title){
super(title);
this.setSize(375, 190);
this.init();
this.setVisible(true);
}
private void init() {
setAlwaysOnTop(true);
JLabel lchoose = new JLabel("Define or Conjugate?");
define = new JButton("Define");
conjugate = new JButton("Conjugate");
close = new JButton("Close");
define.addActionListener(this);
conjugate.addActionListener(this);
close.addActionListener(this);
JPanel panel = new JPanel();
panel.add(lchoose);
panel.add(define);
panel.add(conjugate);
panel.add(close);
this.add(panel);
}
public void setDefaultCloseOperation(int exitOnClose) {}
@Override
public void actionPerformed(ActionEvent event) {
if(event.getSource() == define){
}
else if(event.getSource() == conjugate){
}
else if(event.getSource() == close){
System.exit(0);
}
}
}