I am pretty sure that this question has been asked before, but my case is slightly different as in i am trying to place a JLabel on top of a JLabel acting as a background, I want to display changing numbers using the JLabels and the numbers need to display over the background, however i am a bit of a swing n00b, thanks in advance, Jonathan
Share
Without fully appreciating your requirements, if you simply need to display text over a background image, you’d be better off placing the label on top a custom panel which is capable of painting your background.
You get the benefit of a layout manager without the mess.
I’d start by having a read trough Performing Custom Painting and Graphics2D Trail.
If that seems to daunting,
JLabelis actually a type ofContainer, meaning it can actually ‘contain’ other components.EXAMPLE
Background pane…
Constructed with…
And just to show that I’m not bias ;), an example using labels…