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:
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:
We import the
javax.swing.JFrameclass, which is part of the Swing library.We create a class called
MyFrame.In the
mainmethod, we create an instance ofJFramenamedframe.We set the size of the
JFrameusing thesetSizemethod, specifying the width and height in pixels.We set the default close operation using
setDefaultCloseOperationtoJFrame.EXIT_ON_CLOSE, which means the application will exit when the frame is closed.Finally, we make the
JFramevisible withsetVisible(true).
Demo Day 1 Video:
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