using Layout managers
Hi all
I want to add a picture of a car dashboard onto a frame (in swing), i then want to make the inidicator light flash on the dashboard. I know how to add the picture to a frame but cant figure out a way to have a labelontop of the picture to display the light.
This can be done by using null layout however ive been told not to use it! Any other solutions using layout managers would be grateful.
Thanks in advance.
> Hi all
>
> I want to add a picture of a car dashboard onto a
> frame (in swing), i then want to make the inidicator
> light flash on the dashboard. I know how to add the
> picture to a frame but cant figure out a way to have
> a label ontop of the picture to display the
> light.
>
> This can be done by using null layout however ive
> been told not to use it! Any other solutions using
> layout managers would be grateful.
>
> Thanks in advance.
There are many layout managers. Pick the one that best suits your needs.
I favor java.awt.GridBagLayout.
Good luck.
1) Use a Glass Pane on top of the components and add the flashing light to itOR2) If I remember correctly, you can use an animated gif as an image with swing. (But that "might" look horrible as it would update the whole image). =)Jukka
> 2) If I remember correctly, you can use an animated
> gif as an image with swing. (But that "might" look
> horrible as it would update the whole image). =)
a. If you look inside an animated gif file, you will find a series of images, but they are not necessarily all the same size: after the initial image, they tend to be smaller, and come with dx,dy offsets so that the code that drives the animation knows where to place the updated subimages.
You can use javax.imageio classes to pull apart an animated gif file, by the way.
b. Swing uses double buffering anyway, so flashing isn't an issue.