import java.awt.*; import java.awt.event.*; import javax.swing.*;
class point extends JFrame implements ActionListener { JButton b1,b2; public point() { ImageIcon ico1=new ImageIcon("121.jpg"); JButton b1=new JButton("aaaa",ico1); JButton b2=new JButton("bbbb"); this.setSize(400,300); this.setBackground(Color.lightGray); this.getContentPane().setLayout(new FlowLayout()); this.getContentPane().add(b1); this.getContentPane().add(b2); this.repaint(); b1.addActionListener(this); b2.addActionListener(this); this.setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getSource()==b1) { this.getContentPane().getGraphics().drawString("Bbbb",10,10); } if(e.getSource()==b2) { getGraphics().drawString("Aaaa",10,10); } this.repaint(); this.show(); } public static void main(String atgs[]) { new point(); } }