Wednesday, January 29, 2014

Example of image button in java frame.

import java.awt.event.*;
import javax.swing.*;

public class imageButton
{
imageButton()
{
JFrame f=new JFrame("MaHi");

JButton b=new JButton(new ImageIcon("socials.png"));
b.setBounds(110,140,142,71);
f.add(b);

JLabel l=new JLabel();
l.setText("Social Image Button");
l.setBounds(120,60,150,30);
f.add(l);

f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
}
public static void main(String surat[])
{
new imageButton();
}
}

Output:

No comments:

Post a Comment