Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
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
Tim Cooke
paul wheaton
Paul Clapham
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Saloon Keepers:
Tim Holloway
Carey Brown
Roland Mueller
Piet Souris
Bartenders:
Forum:
Swing / AWT / SWT
set the background of a JPanel with an image
Peter Primrose
Ranch Hand
Posts: 755
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
condsider this:
JPanel p = new JPanel();
p.setBackground(Color.GREEN);
is there anyway to set the background to an image?
I'm looking from some more living colors other than the spectrum provided by swing.
thanks
ppr
Stuart Gray
Ranch Hand
Posts: 410
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I don't think so, but you could maybe fudge it using an ImageIcon.
miguel lisboa
Ranch Hand
Posts: 1282
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import java.awt.*; import javax.swing.*; class Painel extends JPanel { public void paintComponent(Graphics g) { Image imagem = new ImageIcon("MyImage.jpg").getImage(); g.drawImage(imagem, 0, 0, this); } }
java amateur
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
setting background image in applet
image as background to jpanel
JPanel background image
To Display background image in a Jframe/JPanel
How to add backgroung image to JPanel?
More...