Frames
In Java, a frame is a top-level window with a title and a border. Frames are used to create the main application window. The java.awt.Frame class is used to create frames in Java. It provides several methods to manipulate the frame, such as setTitle(), setSize(), setVisible(), and setResizable().
Here’s an example of creating a simple frame:
import java.awt.*;
public class MyFrame extends Frame {
public static void main(String[] args) {
MyFrame frame = new MyFrame();
frame.setTitle(“My Frame”);
frame.setSize(300, 200);
frame.setVisible(true);
}
}
This creates a new MyFrame object, sets its title to “My Frame”, sets its size to 300×200 pixels, and makes it visible. The java.awt.Frame class also provides several event handling methods, such as addWindowListener() and addWindowStateListener(), which can be used to respond to frame events such as window opening, closing, resizing, and iconifying.
Apply for Core Java Developer Certification Now!!
https://www.vskills.in/certification/certified-core-java-developer