1

我的代码有问题。具体这个。当我在 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();
            }
        });
    }
}
4

1 回答 1

0

将您的课程公开,主要方法将被找到并正常运行。

于 2013-04-09T04:22:12.850 回答