Java Swing Program to demonstrate JButton with Icon
Program
import javax.swing.*;
public class JButtonIconDemo
{
public static void main(String args[])
{
JFrame frm = new JFrame("JButton Demo");
JButton btnSubmit;
ImageIcon icoSubmit;
icoSubmit = new ImageIcon("login.png");
btnSubmit = new JButton(icoSubmit);
btnSubmit.setBounds(0, 0, 100, 50);
frm.add(btnSubmit);
frm.setSize(300, 300);
frm.setLayout(null);
frm.setVisible(true);
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Output