This week's book giveaway is in the Android forum.
We're giving away four copies of Learning Java by Building Android Games and have Jean-Marcel Belmont on-line!
See this thread for details.
Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

To Display background image in a Jframe/JPanel  RSS feed

 
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?
 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!