View Single Post
Old Apr 26th, 2005, 6:36 AM   #4
Easter Bunny
Programmer
 
Easter Bunny's Avatar
 
Join Date: Mar 2005
Location: different places. constantly on the run.
Posts: 57
Rep Power: 4 Easter Bunny is on a distinguished road
you mean something like this?

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

public class ImageButton extends JButton
{
	public static void main( String[] args )
	{
		JFrame frame = new JFrame();
		
		ImageIcon image = new ImageIcon( "c:\\pic.gif" );
		
		JPanel panel = new JPanel();
		panel.add( new ImageButton( image ) );
		
		frame.getContentPane().add( panel );
		frame.setSize( 200, 200 );
		frame.setVisible( true );
	}
	
	public ImageButton( ImageIcon im )
	{
		super( im );
		
		setPreferredSize( new Dimension( 50, 50 ) );
	}
}

that's the first thing that jumped to mind. if you compile and run that, then you must obviously have a "pic.gif" in your c:.
__________________
There's got to be more to life than being really, really
ridiculously good looking
Easter Bunny is offline   Reply With Quote