This is probably a stupid question but i have been searching for the answere all day know, and i can't find it.
I'm following a Java course on an University and when i create new JFrame ( only create by typing in a name and klik create) the code does not look the same as in the course. I get a main method and in the course they get a default constructor.
i get:
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
jkksl frame = new jkksl();
frame.setVisible(true);
}
catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public jkksl() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
}
It creates a public static void main()
automatically, but when they do the same in the course (only create a new JFrame), the basic code they get is:
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
/**
* This is the default constructor
*/
public variabelveld2() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(300, 200);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
}
return jContentPane;
}
When only creating a JFrame, so not typing in any code, the code doesn't have a main and does get a default constructor with super()
and initialize()
.
I can't seem to find why they get the default constructor and i get a main method and how i can change the settings so i also get a default constructor with super()
and initialize()
.
Can someone please help?