我的代码存在问题。特别是这个。当我在Netbeans中编译它时,它说“无法找到或加载主类表单”,但我在代码中看到它...我做错了什么?
其次,要将它嵌入网页,我可以编译它吗?谢谢您的帮助。我只用了一周的Java GUI。
package gui;
import java.applet.Applet;
import java.awt.*;
import java.awt.EventQueue;
import java.awt.GridLayout;
import javax.swing.*;
class Form {
private static void display() {
JTextField field1 = new JTextField();
JTextField field2 = new JTextField();
JTextField field3 = new JTextField();
JTextField field4 = new JTextField();
JTextField field5 = new JTextField();
JPanel panel = new JPanel(new GridLayout(0, 1));
panel.add(new JLabel("Username:"));
panel.add(field1);
panel.add(new JLabel("Password:"));
panel.add(field2);
panel.add(new JLabel("Repeat Password:"));
panel.add(field3);
panel.add(new JLabel("Email address:"));
panel.add(field4);
panel.add(new JLabel("Repeat email address:"));
panel.add(field5);
int result = JOptionPane.showConfirmDialog(null, panel, "Form",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
display();
}
});
}
}
答案 0 :(得分:0)
让您的课程公开,主要方法将被找到并正确运行。