import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Simple implements ActionListener
{
//GUI Declaration Part
JButton b1 = new JButton ("My Button");
JTextArea ta = new JTextArea();
public static void main(String ar[])
{
Simple s = new Simple();
s.design();
}
//Designing part
public void design()
{
JFrame frame = new JFrame("Simple");
b1.addActionListener(this);
frame.getContentPane().add(BorderLayout.EAST,b1);
frame.getContentPane().add(BorderLayout.CENTER,ta);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500,500);
frame.setVisible(true);
}
//Event Handling Part
public void actionPerformed(ActionEvent ae)
{
b1.setText("Clicked");
ta.setText("I have Clicked on the button, you see that");
}
}
No comments:
Post a Comment