Monday, February 26, 2018

Java Swing program : A button with Icon

 import javax.swing.*;     
    public class ButtonWithIcon{   
    ButtonWithIcon(){   
    JFrame f=new JFrame("ButtonWithIcon");           
    JButton b=new JButton(new ImageIcon("D:\\JavaSwing\\lcd.png"));   
    b.setBounds(50,100,230, 130);   
    f.add(b);   
    f.setSize(400,400);   
    f.setLayout(null);   
    f.setVisible(true);   
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   
        }        
    public static void main(String[] args) {   
        new ButtonWithIcon();   
    }   
    }   
Output

Thanks
Happy programming!

No comments:

Post a Comment

Sacred Thought

26 April 2024  Dear friends, I write the explanation of two verses of Geets for all of you, I hope you all will like it and benefit from it....