[英]Java how to start up the GUI made with IntelliJ IDEA
I have made a simple GUI using IntelliJ-IDEA and I can't figure out how to start it up. 我已经使用IntelliJ-IDEA制作了一个简单的GUI,但我不知道如何启动它。 Something like
Form1 f = new Form();
如
Form1 f = new Form();
inside my main()
function doesn't seem to do anything. 我的
main()
函数内部似乎什么也没做。 Does anyone know how to start it up ? 有谁知道如何启动它?
public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
Form1 t = new Form1();
}
}
I had to add a couple of lines more than expected. 我不得不多加几行,超出预期。 Here is how my working code looks like for the
Form1.java
file. 这是
Form1.java
文件的工作代码。 I didn't change my main()
fucntion. 我没有更改
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);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.