• 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!