gpt4 book ai didi

java swing错误对话框

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:44:46 24 4
gpt4 key购买 nike

我有一个要显示的对话框,但它给出了编译错误。编译错误在最后部分给出。

import javax.swing.*;

class SwingDemo {
SwingDemo() {
JFrame jfrm = new JFrame("A Simple Swing Application");
jfrm.setSize(275, 100);
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel jlab = new JLabel(" Swing means powerful GUIs.");
jfrm.add(jlab);
jfrm.setVisible(true);
}

public static void main(String args[]) {
public void run() {
new SwingDemo();
}
}
}

错误是:

Multiple markers at this line
- Syntax error on token "void", @ expected
- Syntax error, insert "enum Identifier" to complete EnumHeaderName
- Syntax error, insert "EnumBody" to complete BlockStatements

最佳答案

只需用这个替换您的主要功能即可。

public static void main(String args[]) {
// Create the frame on the event dispatching thread.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new SwingDemo();
}
});
}

关于java swing错误对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27590169/

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