import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class jbutton extends JFrame {
private JButton reg;
private JButton custom;
public jbutton(){
super("Buttons");
setLayout(new FlowLayout());
reg = new JButton("reg button");
add(reg);
Icon b = new ImageIcon(getClass().getResource("b.png"));
Icon x = new ImageIcon(getClass().getResource("x.png"));
custom = new JButton("Custom",b);
custom.setRolloverIcon(x);
add(custom);
handclass handler = new handclass();
reg.addActionListener(handler);
custom.addActionListener(handler);
}
public class handclass implements ActionListener{
public void actionPerformed(ActionEvent event){
JOptionPane.showMessageDialog(null, String.format("%s", event.getActionCommand()));
}
}
}