NetBeans Swing Form Background Color
Page 1 of 1
NetBeans Swing Form Background Color Can't seem to get it to change
#1
Posted 28 June 2008 - 01:38 PM
Well, I am using NetBeans, using the Swing GUI Creator. The problem is, I have changed the background color property to the standard black [0, 0, 0] color. The problem is, at runtime, the color isn't actually changed, it stays the default kinda greyish color.
Any ideas?
Any ideas?
#3
Posted 28 June 2008 - 03:15 PM
I set the background of the form, not just 1 component. I don't have another form at the moment, and only 1 button on my current form, so it's pretty difficult (I believe) for NetBeans to screw this up.
The setBackground(new java.awt.Color(0, 0, 0)) command is correct, since it's just doing this to the form...
EDIT: ARGH, I hate the way NetBeans generates code. (I just switched the brace locations.)
private void initComponents()
{
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Login");
setAlwaysOnTop(true);
setBackground(new java.awt.Color(0, 0, 0));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setResizable(false);
jButton1.setText("Login");
jButton1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(142, 142, 142)
.addComponent(jButton1)
.addContainerGap(149, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(167, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(41, 41, 41))
);
jButton1.getAccessibleContext().setAccessibleName(null);
pack();
}// </editor-fold>
The setBackground(new java.awt.Color(0, 0, 0)) command is correct, since it's just doing this to the form...
EDIT: ARGH, I hate the way NetBeans generates code. (I just switched the brace locations.)
This post has been edited by Locke37: 28 June 2008 - 03:17 PM
#5
Posted 29 June 2008 - 04:51 PM
Well that's odd...I don't know quite why that worked. Since you would THINK that NetBeans would be smart enough to do that on it's own since I set the property on the form the same as I did in the code.
I still don't know why it doesnt do that automatically...But thanks all the same!
private LoginForm()
{
initComponents();
getContentPane().setBackground(java.awt.Color.black);
}
I still don't know why it doesnt do that automatically...But thanks all the same!
#12
Posted 06 July 2008 - 07:41 AM
I'm not sure how you are doing it in netbeans, but if you are asking it to change the background color of the JFrame, then it is doing exactly what it should. The JFrame has a background color, but the entire contents of a JFrame are covered by the content pane, so you need to change to color of the content pane, not the JFrame. Otherwise the content pane simply covers the JFrame and there is no change.
Page 1 of 1

Start a new topic
Add Reply





MultiQuote



| 


