Java: how to show Hello World! after clicking on the button

advertisements

I would like to learn how you go to a next 'frame or screen' in Java.

I'm learning Java and got the Hello World App working, My next step is to have a button and after its being clicked I want the Hello World! to appear.

So first the button and then the Hello World in the next 'frame' I call it frames but don't know how it's called for Java. I use windows7 and notepad by the way

How do I do this?


First, find a swing tutorial that fits you. There are many, such as this and this (first on google...)

Basically, you need to put a JButton in a JPanel and then put the JPanel in your main JFrame. Also, to display the "hello world" screen you need to create ActionListener that displays it and add it to your button.