Swing JButton Icon in Java Example
Chapter:
Swing
Last Updated:
12-06-2016 19:10:39 UTC
Program:
/* ............... START ............... */
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
public class JavaSwingJButtonIcon {
public static void main(String[] args) {
JFrame frame = new JFrame("Button Image Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Icon imageIcon = new ImageIcon("Tick.jpg");
JButton button2 = new JButton(imageIcon);
frame.add(button2);
frame.setSize(300, 200);
frame.setVisible(true);
}
}
/* ............... END ............... */
Output
Tags
Swing JButton Icon, Java