Page 205 - CITS - CSA - TP (Volume 2) - Hindi
P. 205
कं ूटर सॉ वेयर ए ीके शन - CITS
टा 2: लेबल और िवंडो इव ट ह डिलंग के साथ एक सरल ािफ़कल िवंडो ( े म)
import java.awt.Frame;
import java.awt.Label;
// CustomFrame class extending Frame
class CustomFrame extends Frame {
public CustomFrame(String title) {
super(title);
}
}
// Main class demonstrating the usage
public class ContainerExample {
public static void main(String[] args) {
// Creating an instance of CustomFrame
CustomFrame customFrame = new CustomFrame(“Custom Container Example”);
// Adding a label to the custom frame
Label label = new Label(“Hello, this is a simple container!”);
customFrame.add(label);
// Setting size and visibility
customFrame.setSize(300, 200);
customFrame.setVisible(true);
// Adding window close event handling
customFrame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent windowEvent) {
System.exit(0);
}
});
}}
आउटपुट:
191
CITS : IT & ITES - कं ूटर सॉ वेयर ए ीके शन - अ ास 116

