Jframe Java

Share

Jframe Java

A JFrame is a class in Java that is part of the Swing library and is used to create graphical user interface (GUI) windows for desktop applications. It provides a top-level container for building graphical applications. Here’s a basic example of how to create a simple JFrame in Java:

java
import javax.swing.JFrame; public class MyFrame { public static void main(String[] args) { // Create a JFrame instance JFrame frame = new JFrame("My First JFrame"); // Set the size of the JFrame (width, height) frame.setSize(400, 300); // Set the default close operation to exit the application when the frame is closed frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Make the JFrame visible frame.setVisible(true); } }

In this example:

  1. We import the javax.swing.JFrame class, which is part of the Swing library.

  2. We create a class called MyFrame.

  3. In the main method, we create an instance of JFrame named frame.

  4. We set the size of the JFrame using the setSize method, specifying the width and height in pixels.

  5. We set the default close operation using setDefaultCloseOperation to JFrame.EXIT_ON_CLOSE, which means the application will exit when the frame is closed.

  6. Finally, we make the JFrame visible with setVisible(true).

Demo Day 1 Video:

 
You can find more information about Java in this Java Docs Link

 

Conclusion:

Unogeeks is the No.1 Training Institute for Java Training. Anyone Disagree? Please drop in a comment

You can check out our other latest blogs on Java Training here – Java Blogs

You can check out our Best in Class Java Training details here – Java Training

💬 Follow & Connect with us:

———————————-

For Training inquiries:

Call/Whatsapp: +91 73960 33555

Mail us at: info@unogeeks.com

Our Website ➜ https://unogeeks.com

Follow us:

Instagram: https://www.instagram.com/unogeeks

Facebook: https://www.facebook.com/UnogeeksSoftwareTrainingInstitute

Twitter: https://twitter.com/unogeeks


Share

Leave a Reply

Your email address will not be published. Required fields are marked *