how to put an image in a button?thanx :)

Recommended Answers

All 3 Replies

Use an ImageIcon. Take a look through the tutorial on buttons.

32x32/16x16 in pixels

// Use an imageicon and you can add icon within constructor or use b.setIcon( icon )

ImageIcon icon = new ImageIcon( "a.jpg" );
JButton b = new JButton( "Click", icon );

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.