Re: JFrame Background Color
On Sep 19, 12:05 am, "John B. Matthews" <nos...@nospam.invalid> wrote:
In article <wTelo.36842$y85.9...@newsfe13.iad>,
Knute Johnson <nos...@rabbitbrush.frazmtn.com> wrote:
On 9/18/2010 7:42 PM, bruce wrote:
I'm new at this NetBeans/Java stuff and appreciate the help.
How do I set the background color on my initial JFrame when
creating a GUI page? I went to the properties window and set the
background property and nothing seemed to happen. No problem
setting the background on JPanels object.
What I thought of was placing a "Master JPanel" that would cover
the complete JFrame.. Seems "Hookey" but maybe that's the correct
way to do what I want to do..
import java.awt.*;
import javax.swing.*;
public class test extends JFrame {
public test() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setBackground(Color.BLUE);
setSize(400,300);
setVisible(true);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
new test();
}
});
}
}
bruce: When I chose File > New File > Swing GUI Forms > JFrame Form,
the resulting design showed "background" among the "Other Properties",
and the displayed background reflected the chosen color. I found it
instructive to compare the generated code with Knute Johnson's example.
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
John: Before I made my original message post, I tried to change the
background property, under other properties. No Joy!!
I tried to follow your senerio: File > New File? Swing GUI Forms ?
JFrame Form > Next > Finish. I then went to the properties, found
backgound color under "Other Properties" and set it to 0,0,255. Save.
Again, No joy..
No sure how you were able to get it work an I can't..
I'm using: Product Version: NetBeans IDE 6.7.1 (Build 200907230233)
Bruce