Thursday 12 December 2013

Java: GUI application open new form with button (part 3)

Part 3 of the tutorial, how to create a GUI application with multi forms in JAVA

Coding the main Form

To make things easy you can double click the button, it will open the code to the actionEvent.
The first thing we are going to do is to declare and initialise the new form.  We will command it to show the new screen.  We will observe what happens when we close the new form.

So double click the button, we will be shown in the ActionEvent code.  We will initialise the new form and we will set the visibility to true
NewForm newForm = new NewForm();
newForm.setVisible(true);
If we run our code, we will see the our form with a button;


Click the Start new JFrame button.

What is the response of the application?

What happens when we press X on the new JFrame?


Yes the application gets terminated.  But why?

We will discuss it to part 4

No comments:

Post a Comment

Reset numbering for Screenshots Win+PrtSc

I was using today the screen shot functionality of Windows 8.1 Win Key + PrtSc How to reset the numbering?