Friday, September 26, 2008

Show Icon on The Button

With the help of java swing, you can add images, icons in the application to make your GUI application interface more attractive. With the help of this example, you can learn how to add image on the button or other control. This example expain you add image file. The code is given below :

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

public class IconButton{
public static void main(String[] args){
JFrame frame = new JFrame("Swing Icon Example");
JButton button = new JButton("My Button");
Icon imgicon = new ImageIcon("smiley_icon.gif");
JPanel panel = new JPanel();
frame.add(panel, BorderLayout.NORTH);
frame.setSize(380, 380);


PdAnuva said...

Nice Post
SEO Services

Jeena said...

I did this , but i got error on this, can u clear me Car DVD Systems