0% found this document useful (0 votes)
17 views1 page

Creating A GUI

A JFrame is created and sized to 400x300 pixels and centered on the screen. It is set to close the application when closed. A "OK" button is added to the frame before setting it to visible. The document then introduces layout managers.

Uploaded by

TedrosSailh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Creating A GUI

A JFrame is created and sized to 400x300 pixels and centered on the screen. It is set to close the application when closed. A "OK" button is added to the frame before setting it to visible. The document then introduces layout managers.

Uploaded by

TedrosSailh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Creating a Frame

JFrame frame = new JFrame("MyFrame"); // Create a frame


frame.setSize(400, 300); // Set the frame size
frame.setLocationRelativeTo(null);// Center a frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true); // Display the frame

ADD BUTTON TO A FRAME:


JButton jok= new JButton("OK");
frame.add(jok);

Layout Managers

You might also like