Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with setting JFrame's background colour..

843806Jun 6 2007 — edited Jun 6 2007
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,,,
public class test2 extends 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 ">                          
    private void 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
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void 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..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 4 2007
Added on Jun 6 2007
1 comment
90 views