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!
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