gpt4 book ai didi

java - FPL论坛申请

转载 作者:行者123 更新时间:2023-12-01 10:41:20 25 4
gpt4 key购买 nike

我正在尝试创建一个专业的登录/注册表单,但此刻我的代码无法正常工作:它将用于我通过 NetBeans 创建的 FPL 论坛。

任何有关该主题的帮助将不胜感激。

    package fplforum;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class RegistrationForm extends JFrame implements ActionListener {
public RegistrationPanel panel;
public JButton submit, cancel;
public boolean done;
public Object UITools;

public RegistrationForm() {
JPanel main = new JPanel();
main.setLayout(new BorderLayout());
main.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));

JLabel label = new JLabel("Java CoG Kit Registration");
label.setFont(Font.decode("Arial-bold-18"));
label.setBorder(BorderFactory.createEmptyBorder(5, 10, 20, 10));

main.add(label, BorderLayout.NORTH);

panel = new RegistrationPanel();
//panel.getReregister().addActionListener(this);
//main.add(panel, BorderLayout.CENTER);
setTitle("Java CoG Kit Registration Form");

JPanel buttons = new JPanel();
buttons.setLayout(new FlowLayout());

submit = new JButton("Submit");
submit.addActionListener(this);
buttons.add(submit);

//submit.setEnabled(panel.getReregister().isSelected());

cancel = new JButton("Cancel");
cancel.addActionListener(this);
buttons.add(cancel);

main.add(buttons, BorderLayout.SOUTH);

getContentPane().add(main);
}

@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == submit) {
try {
panel.submit(false);
JOptionPane.showMessageDialog(this, "Thank you for registering the Java CoG Kit",
"Registration successful", JOptionPane.INFORMATION_MESSAGE);
done();
}
catch (IOException e1) {
JOptionPane.showMessageDialog(this, "Could not submit registration information: "
+ e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
else if (e.getSource() == cancel) {
done();
}
else {
//must be the don't send switch
submit.setEnabled(panel.getReregister().isSelected());
}
}

private void done() {
done = true;
synchronized (this) {
notify();
}
}

public void run() {
setSize(500, 380);
UITools.left(null, this);
setVisible(true);
try {
synchronized (this) {
while (!done) {
wait();
}
}
}
catch (InterruptedException e) {
JOptionPane.showMessageDialog(this, "The main thread was interrupted", "Error",
JOptionPane.ERROR_MESSAGE);
}
setVisible(false);
dispose();
}

public static void main(String[] args) {
//RegistrationFrame frame = new RegistrationFrame();
//frame.run();
//System.exit(0);
}

private static class RegistrationPanel {

public RegistrationPanel() {
}

private Object getReregister() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

private void submit(boolean b) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
}

它可以编译,但没有任何反应,我该如何解决它?

最佳答案

如果编译并执行,那么它就可以工作。它并不像你希望的那样工作,但它确实有效。您有一个空的 main 方法,因此它不会执行任何操作。这是您的主要方法:

public static void main(String[] args) {
//RegistrationFrame frame = new RegistrationFrame();
//frame.run();
//System.exit(0);
}

所有行都被注释掉,因此没有要执行的操作。取出行开头的 // 来执行一些操作。另外,据我所知,您没有 RegistrationFrame class,您可能想实例化 RegistrationForm 。另外,为什么要调用 System.exit(0)

关于java - FPL论坛申请,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34399081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com