LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-19-2011, 08:03 AM   #1
nine9nine
Member
 
Registered: Jan 2011
Distribution: Ubuntu
Posts: 123

Rep: Reputation: 1
Java: Set background image JFrame


Hi, everyone. I am learning some Java programming, and I've run into a problem. I am trying to set a background for JFrame, so that I can put text and buttons on it. I've tried searching the internet, and the only code that I found that was a full code (I lost it, and don't remember the link) had so much other stuff, such as text and buttons, that I couldn't find the part I needed. Also, it could help if someone could tell me how to change text color.

Thanks in advance.
 
Old 07-19-2011, 01:48 PM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Perhaps you want to add your text and button(s) to one or more JPanel objects; these in turn are added to the JFrame.

The JLabel color can be changed using setBackground() and/or setForeground().

You should bookmark the Java API page: http://download.oracle.com/javase/6/docs/api/
 
Old 07-20-2011, 08:16 AM   #3
nine9nine
Member
 
Registered: Jan 2011
Distribution: Ubuntu
Posts: 123

Original Poster
Rep: Reputation: 1
I know how to change the color, though I can't find a way to set an image as the background. How do I do that?
 
Old 07-20-2011, 11:25 AM   #4
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Have you thought about Googling (again?) for the code that you found originally?

Using these keywords, "JFrame set background color", the first result I found seemed helpful enough; in case you don't know how to use Google, here's the link: http://javaallinone.blogspot.com/200...on-jframe.html
 
Old 07-21-2011, 11:45 AM   #5
nine9nine
Member
 
Registered: Jan 2011
Distribution: Ubuntu
Posts: 123

Original Poster
Rep: Reputation: 1
I found the answer. I have one panel with the picture on it, and then I placed a panel on top of it, and used "panel.setOpaque(false);", which made the panel transparent. This is where I placed everything.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How can I set a root background image? CFet Slackware 3 04-04-2011 09:46 PM
Set background image for Konsole 2??? cweepy Linux - Newbie 2 09-08-2008 11:16 AM
Can't set background image in Icewm gamfa Grafpup 1 06-28-2007 10:28 AM
How to set the login background image when using KDM PTrenholme Fedora 0 04-15-2006 09:20 AM
Can't set desktop background image in Gnome TruckStuff Linux - General 1 07-18-2005 03:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration