Now, how to do that in NetBeans.
1, Create the two JFrames, lets call them FirstFrame.java and
SecondFrame.java.
2, Drag a Button from the Pallete to the FirstFrame (in the GUI designer)
3, Select the Button and in the Properties window (on the right side of the
screen by default, or using right-click menu of the Button) click on
"Events"
4, Now, select the line with 'actionPerformed' and pres the [...] button on
right side -> Handlers dialog should open
5, Add new Handler and name it as you wish (e.g. "openFrame"). Now hit OK
and you will find yourself in source code of the FirstFrame.java.
6, you should see a method called "openFrame", and you can edit it's body
(the surrounding lines have grey background as they are not editable).
Simply write there:
new SecondFrame().setVisible(true);
And that's it! Simple as that. Now if you run the FirstFrame, you should see
your Button and after clicking it, the SecondFrame appears.
You can now explore the code of the FirstFrame a bit. If you expand the
Generated code, you will see that NB prepared the Listener I was talking
about at the beginning automatically. It is the line with
"jButton1.addActionListener..." . You see that the Listener call your method
(handler) called "openFrame".
And that is the whole magic