JDK-4092995 : Swing 0.6 - Can't set the background color of JDialog
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 1997-11-14
  • Updated: 2016-02-18
  • Resolved: 1997-12-12
Related Reports
Relates :  
Description
Using Swing 0.6 and JDK1.2, the background color of JDialog cannot be set.

The application given below creates a JDialog and invokes 
setBackground(Color.green) on it.

On Solaris, when the JDialog is displayed, it flashes green for a brief 
moment, then turns gray.
On NT, it comes up gray.

/*==================================================================*/
/*
 * Swing 0.6 - Can't set the background color of JDialog
*/
import java.awt.swing.*;
import java.awt.*;
import java.awt.event.*;

public class JDialogTest {
   static JFrame frame = new JFrame();
   static JDialog dialog = new JDialog(frame);

   public static void main (String[] args) {
      dialog.setSize(200,200);
      dialog.setBackground(Color.green);    // Green, buddy - not gray
      dialog.setVisible(true);
      
      dialog.addWindowListener (new WindowAdapter () {
         public void windowClosing (WindowEvent e) {
            dialog.dispose ();
            System.exit (0);
            }
         });
   }
}
/*==================================================================*/

Comments
EVALUATION Not a bug, user needs to set background on the content pane for it to be effective, eg: dialog.getContentPane().setBackground(color); sky 1997-12-11
11-06-2004

PUBLIC COMMENTS Not a bug, user needs to set background on the content pane for it to be effective, eg: dialog.getContentPane().setBackground(color); sky 1997-12-11
10-06-2004