• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To Display background image in a Jframe/JPanel

 
satya sahu
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i place a background image for a JFrame/JPanel?.

I have 2 panels within a frame. I need to set a background image for the Frame.

Please lemme know how do i do it?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I need to set a background image for the Frame.

create a JPanel, set to BorderLayout (or whatever), then set the panel as
the contentPane of the frame. Now add components to the panel, as you would
the frame.

the swing FAQ (link on swing main page, above topics) has an example of a
JPanel with background image - this is what you'd use for your contentPane
 
satya sahu
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i have a panel in the Frame, where i have to put the background image and also i have few swing controls(labels, combobox, textbox....). So if possible can somebody please give me some sample code or some related links.

Please help me ASAP.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> So if possible can somebody please give me some sample code

sample code of what?

the link shows you how to have a JPanel with a background image,
all you then do is add components to the panel, as you would a normal JPanel.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic