Saturday, 13 February 2016

How to make ImageButton in java

Program


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

public class ImgButton
{
   public static void main(String[] args)
   {

     JFrame f = new JFrame("welcome");
     ImageIcon img = new ImageIcon("roses.jpg");

     JButton b1 = new JButton(img);

    f.add(b1);
    f.setSize(1000,200);
    f.setLayout(new FlowLayout(FlowLayout.CENTER));
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

     }
}
 

Output


No comments:

Post a Comment