Java Code
/** Example showing use of JButton with images
* @author : E.S.Boese (c) Fall 2007
*/
import javax.swing.*;
import java.awt.*;
public class JButtonImgMethods extends JApplet
{
JButton one, two, three;
Image img;
ImageIcon icon;
public void init( )
{
setLayout( new FlowLayout( ) );
setupButtons( );
}
public void setupButtons( )
{
one = new JButton( "one" );
img = getImage( getCodeBase( ), "idea.png" );
icon = new ImageIcon( img );
two = new JButton( icon );
img = getImage( getCodeBase( ), "oncomputer.png" );
three = new JButton( "three", new ImageIcon( img ));
add( one );
add( two );
add( three );
}
}
Back to Code Examples
©2006-
by E.S.Boese. All Rights Reserved