Java Swing Program to demonstrate JButton with Text and Icon
Program
import javax.swing.*;
public class JButtonTextIconDemo
{
public static void main(String[] args)
{
JFrame frm = new JFrame("JButton Demo");
JButton btnSubmit;
ImageIcon icoSubmit;
icoSubmit = new ImageIcon("login.png");
btnSubmit = new JButton();
btnSubmit.setText("Login");
btnSubmit.setIcon(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