• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

To Display background image in a Jframe/JPanel

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic