Reputation: 4273
I have made a simple GUI using IntelliJ-IDEA and I can't figure out how to start it up. Something like Form1 f = new Form();
inside my main()
function doesn't seem to do anything. 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();
}
}
Upvotes: 0
Views: 1220
Reputation: 4273
I had to add a couple of lines more than expected. Here is how my working code looks like for the Form1.java
file. I didn't change my main()
fucntion.
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);
}
}
Upvotes: 1