import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Draw implements ActionListener
{
JFrame f;
JButton b1;
JButton b2;
JButton b3;
JLabel lb;
public Draw()
{
f=new JFrame();
b1=new JButton("RED");
b2=new JButton("GREEN");
b3=new JButton("ORANGE");
lb=new JLabel();
Shape s=new Shape();
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
f.add(BorderLayout.CENTER,s);
lb.setForeground(Color.white);
f.add(BorderLayout.NORTH,lb);
f.add(BorderLayout.SOUTH,b1);
f.add(BorderLayout.WEST,b2);
f.add(BorderLayout.EAST,b3);
f.setVisible(true);
f.setSize(400,400);
}
public void actionPerformed(ActionEvent ae)
{
}
public void paintComponent(Graphics g)
{
g.setColor(Color.red);
g.fillRect(20,30,110,110);
}
public static void main(String[] args)
{
Draw a=new Draw();
}
}
No comments:
Post a Comment