public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(this,e.getSource()); }
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class fdemo extends JFrame implements ActionListener { fdemo() { super("MyFrame"); JButton a = new JButton("a"); JButton b = new JButton("b"); JButton c = new JButton("c"); a.addActionListener(this); b.addActionListener(this); c.addActionListener(this); add(a,BorderLayout.NORTH); add(b,BorderLayout.CENTER); add(c,BorderLayout.SOUTH); setSize(200,200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(this,e.getSource()); } public static void main(String args[]) { new fdemo(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)