我知道以前有人问过这个问题……只是其他问题的答案都没有。当我尝试在 Eclipse 中运行它时,我只是进入Error: Could not find or load main class Hey.Init
控制台。“嘿”是包裹。
我可以发布第三节课,我认为这不相关。
package Hey;
import javax.swing.SwingUtilities;
public class Init {
static Runnable createGui = new Runnable(){
public void run(){
new Gui();
}
};
public static void main(String[] args){
SwingUtilities.invokeLater(createGui);
}
}
其他类:
package Hey;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Gui {
private JFrame frame = new JFrame("Title");
private JButton button;
public Gui(){
frame.setLayout(new FlowLayout());
button = new JButton("DON'T HIT ME!!!");
button.addMouseListener(new Yo());
}
}