package three.day.frame;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
public class JButtonIconChange {
public static void main(String[] args) {
JFrame frame = new JFrame("JButton Icon Change");
JButton bt = new JButton();
bt.setRolloverEnabled(true);
Icon rvIcon = new ImageIcon("1.jpg");
bt.setRolloverIcon(rvIcon);
Icon icon = new ImageIcon("2.jpg");
bt.setIcon(icon);
Icon pressIcon = new ImageIcon("3.jpg");
bt.setPressedIcon(pressIcon);
bt.setRolloverSelectedIcon(icon);
frame.getContentPane().add(bt);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
public class JButtonIconChange {
public static void main(String[] args) {
JFrame frame = new JFrame("JButton Icon Change");
JButton bt = new JButton();
bt.setRolloverEnabled(true);
Icon rvIcon = new ImageIcon("1.jpg");
bt.setRolloverIcon(rvIcon);
Icon icon = new ImageIcon("2.jpg");
bt.setIcon(icon);
Icon pressIcon = new ImageIcon("3.jpg");
bt.setPressedIcon(pressIcon);
bt.setRolloverSelectedIcon(icon);
frame.getContentPane().add(bt);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}