images in buttons

P

patrick

4 JButtons in a JPanel. Im trying to add .gif images so that the images are
centered in the buttons.And will stay centered if the application is resized
or the screen resolution is changed.
How do I go about this?

Do I make images Photoshop with the same pixel size as the buttons, or same
inch dimensions (at some resolution)

when the screen resolution is changed does the image get resized in
proportion alsoalso?
The JPanel will be Flow layout i think.


patrick
 
M

Marco Parmeggiani

4 JButtons in a JPanel. Im trying to add .gif images so that the images are
centered in the buttons.And will stay centered if the application is resized
or the screen resolution is changed.
How do I go about this?

create an Image from the gif :
Toolkit.getDefaultToolkit().createImage(...)
create an ImageIcon from the Image
set the ImageIcon as the icon of your JButton
see JButton properties to set how the icon will be placed in the JButton

ciao
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top