Problem with setting JFrame's background colour..

Hi there!!

I'm having some problems setting the background colour for my window.When I run the code the background colour is shown but just for a split second and then it disappears,,here's the code,,,

publicclass test2extends javax.swing.JFrame{

/** Creates new form test2 */

public test2(){

initComponents();

}

/** This method is called from within the constructor to

* initialize the form.

* WARNING: Do NOT modify this code. The content of this method is

* always regenerated by the Form Editor.

*/

// <editor-fold defaultstate="collapsed" desc=" Generated Code ">

privatevoid initComponents(){

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setBackground(new java.awt.Color(0, 255, 51));

org.jdesktop.layout.GroupLayout layout =new org.jdesktop.layout.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(0, 649, Short.MAX_VALUE)

);

layout.setVerticalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(0, 592, Short.MAX_VALUE)

);

pack();

}// </editor-fold>

/**

* @param args the command line arguments

*/

publicstaticvoid main(String args[]){

java.awt.EventQueue.invokeLater(new Runnable(){

publicvoid run(){

new test2().setVisible(true);

}

});

}

// Variables declaration - do not modify

// End of variables declaration

}

Can you please tell me what's the problem?

Thanks in advance..

[2800 byte] By [Kami_Pakistana] at [2007-11-27 6:35:06]
# 1

The

setBackground(new java.awt.Color(0, 255, 51));

sets the Background color of the Frame, the color you see in you Application is the one of the ContentPane which is embedded into the frame. So

getContentPane().setBackground(new java.awt.Color(0, 255, 51));

shoud do the trick.

marco@dea at 2007-7-12 18:02:01 > top of Java-index,Desktop,Core GUI APIs...