From 9b0e77aa465d814b444a4910c03440622718b40c Mon Sep 17 00:00:00 2001 From: 23-spurtiNarkhedkar <86821974+23-spurtiNarkhedkar@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:41:36 +0530 Subject: [PATCH] AwtPrac Abstract window toolkit --- AwtPrac.java | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 AwtPrac.java diff --git a/AwtPrac.java b/AwtPrac.java new file mode 100644 index 0000000..d613398 --- /dev/null +++ b/AwtPrac.java @@ -0,0 +1,37 @@ +import java.awt.*; +import java.awt.event.*; + +class AwtPrac extends Frame implements ActionListener { + + TextField tf1; + + AwtPrac() { + tf1 = new TextField(); + tf1.setBounds(50, 50, 200, 30); + Button b1 = new Button("Display msg"); + b1.setBounds(60, 140, 200, 40); + setTitle("Event Handling"); + + b1.addActionListener(this); + add(b1); + add(tf1); + setSize(300, 250); + setLayout(null); + setVisible(true); + + } + + public void actionPerformed(ActionEvent e) { + tf1.setText("Example of event handling(awt)"); + } + + + // main method + public static void main(String args[]) { + + // creating instance of Frame class + new AwtPrac(); + AwtPrac.setDefault.EXIT_ON_CLOSE(); + } + +}