Java Code:
import java.awt.Container;
import java.awt.FlowLayout;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

public class FancyButton extends JButton {
  public FancyButton(Icon icon, Icon pressed, Icon rollover) {
    super(icon);
    setFocusPainted(false);
    setRolloverEnabled(true);
    setRolloverIcon(rollover);
    setPressedIcon(pressed);
    setBorderPainted(false);
    setContentAreaFilled(false);
  }

  // A simple test program
  public static void main(String[] args) {

    FancyButton b1 = new FancyButton(new ImageIcon("1.gif"),
        new ImageIcon("2.gif"), new ImageIcon(
            "3.gif"));
    FancyButton b2 = new FancyButton(new ImageIcon("4.gif"),
        new ImageIcon("1.gif"), new ImageIcon(
            "2.gif"));
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container c = f.getContentPane();
    c.setLayout(new FlowLayout());
    c.add(b1);
    c.add(b2);
    f.pack();
    f.setVisible(true);
  }
}