gpt4 book ai didi

Java如何启动IntelliJ IDEA制作的GUI

转载 作者:行者123 更新时间:2023-12-01 11:24:36 24 4
gpt4 key购买 nike

我使用 IntelliJ-IDEA 制作了一个简单的 GUI,但我不知道如何启动它。我的 main() 函数中类似 Form1 f = new Form(); 的东西似乎没有做任何事情。有谁知道如何启动它吗?

public class Main {

public static void main(String[] args) {
System.out.println("Hello World!");
Form1 t = new Form1();
}
}

1

最佳答案

我不得不比预期多添加几行。以下是 Form1.java 文件的工作代码。我没有更改我的 main() 函数。

public class Form1 extends JFrame {

// ******** These are just auto-generated from the IDE ********
private JPanel panel1;
private JButton button1;
private JButton bb137;
private JButton button3;
private JButton button4;
private JButton button5;
private JButton button6;
private JButton button7;
private JCheckBox checkBox1;
private JRadioButton radioButton1;
private JRadioButton radioButton2;
private JRadioButton radioButton3;
// ************************************************************

public Form1(){
super("Whatever form title here.");
// panel1 is my main panel as you can see in my question's screenshot
setContentPane(panel1);
//x , y, width, height
setBounds(300,300,600,600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}

关于Java如何启动IntelliJ IDEA制作的GUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30940223/

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