The following code will create a simple GUI using the GridLayout manager.
Copy and paste this into the main method of your Project.


JFrame frame = new JFrame("Frame Demo");

Container contentPane = frame.getContentPane();
contentPane.setLayout(new GridLayout(2,4));

//2. Optional: What happens when the frame closes?
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//3. Create components and put them in the frame.
JLabel welcomeLabel = new JLabel("Welcome to JAVA!!");
contentPane.add(welcomeLabel);

JLabel promptLabel = new JLabel("Please Click OK");
contentPane.add(promptLabel);

JLabel nameLabel = new JLabel("Your Name will go Here!");
contentPane.add(nameLabel);

JButton ok = new JButton("OK");
contentPane.add(ok);

//4. Size the frame.
frame.pack();

//5. Show it.
frame.setVisible(true);