-
Bug
-
Resolution: Fixed
-
P3
-
1.1.2, 1.1.3, 1.1.4, 1.2.0
-
1.2fcs
-
x86
-
windows_95, windows_nt
-
Verified
The application given below shows differing behavior on Windows NT and
Solaris.
The application invokes setBackground(Color.green) on a dialog.
The dialog comes up with a green background on Solaris, but with a
grey background on Windows NT.
To recreate, start the application and click the "Show Modal Dialog"
button.
=======================================================================
/* ModalDialogDisplayer.java
* Modal Dialog displayer
* This applet displays a modal dialog
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class ModalDialogDisplayer extends Applet implements ActionListener
{
static Frame theFrame = new Frame("Modal Dialog Displayer");
static Dialog modalDialog = null;
Button showButton = new Button("Show Modal Dialog");
Button redButton = new Button("Set panel color to red");
Button blueButton = new Button("Set panel color to blue");
Button dismissButton = new Button("Dismiss");
Panel buttonPanel = new Panel();
Panel colorPanel = new Panel();
public ModalDialogDisplayer() {
modalDialog = new Dialog(theFrame, "Modal Dialog", true);
modalDialog.setLayout(new FlowLayout());
modalDialog.setSize(200, 200);
modalDialog.setBackground(Color.green);
dismissButton.setBackground(Color.yellow);
modalDialog.add(dismissButton);
setLayout(new BorderLayout());
showButton.setBackground(Color.yellow);
buttonPanel.add(showButton);
buttonPanel.add(redButton);
buttonPanel.add(blueButton);
colorPanel.setBackground(Color.yellow);
add("North", buttonPanel);
add("Center", colorPanel);
showButton.addActionListener(this);
redButton.addActionListener(this);
blueButton.addActionListener(this);
dismissButton.addActionListener(this);
}
// Make dialog visible
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == "Show Modal Dialog")
modalDialog.setVisible(true);
else if (e.getActionCommand() == "Set panel color to red")
colorPanel.setBackground(Color.red);
else if (e.getActionCommand() == "Set panel color to blue")
colorPanel.setBackground(Color.blue);
else if (e.getActionCommand() == "Dismiss")
modalDialog.dispose();
else {}
}
public void setLocationOfDialog(int x, int y) {
modalDialog.setLocation(x, y);
}
// Remove dialog
public void cleanUp() {
if (modalDialog != null)
modalDialog.dispose();
}
public static void main(String s[]) {
ModalDialogDisplayer displayer = new ModalDialogDisplayer();
theFrame.add("Center", displayer);
theFrame.pack();
theFrame.setSize(500, 300);
theFrame.show();
theFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
if (modalDialog != null)
modalDialog.dispose();
theFrame.dispose();
System.exit(0);
}
public void windowClosed(WindowEvent e) {
if (modalDialog != null)
modalDialog.dispose();
theFrame.dispose();
}
});
}
public void start() {}
public void stop() {}
public void destroy() {}
}
Solaris.
The application invokes setBackground(Color.green) on a dialog.
The dialog comes up with a green background on Solaris, but with a
grey background on Windows NT.
To recreate, start the application and click the "Show Modal Dialog"
button.
=======================================================================
/* ModalDialogDisplayer.java
* Modal Dialog displayer
* This applet displays a modal dialog
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class ModalDialogDisplayer extends Applet implements ActionListener
{
static Frame theFrame = new Frame("Modal Dialog Displayer");
static Dialog modalDialog = null;
Button showButton = new Button("Show Modal Dialog");
Button redButton = new Button("Set panel color to red");
Button blueButton = new Button("Set panel color to blue");
Button dismissButton = new Button("Dismiss");
Panel buttonPanel = new Panel();
Panel colorPanel = new Panel();
public ModalDialogDisplayer() {
modalDialog = new Dialog(theFrame, "Modal Dialog", true);
modalDialog.setLayout(new FlowLayout());
modalDialog.setSize(200, 200);
modalDialog.setBackground(Color.green);
dismissButton.setBackground(Color.yellow);
modalDialog.add(dismissButton);
setLayout(new BorderLayout());
showButton.setBackground(Color.yellow);
buttonPanel.add(showButton);
buttonPanel.add(redButton);
buttonPanel.add(blueButton);
colorPanel.setBackground(Color.yellow);
add("North", buttonPanel);
add("Center", colorPanel);
showButton.addActionListener(this);
redButton.addActionListener(this);
blueButton.addActionListener(this);
dismissButton.addActionListener(this);
}
// Make dialog visible
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == "Show Modal Dialog")
modalDialog.setVisible(true);
else if (e.getActionCommand() == "Set panel color to red")
colorPanel.setBackground(Color.red);
else if (e.getActionCommand() == "Set panel color to blue")
colorPanel.setBackground(Color.blue);
else if (e.getActionCommand() == "Dismiss")
modalDialog.dispose();
else {}
}
public void setLocationOfDialog(int x, int y) {
modalDialog.setLocation(x, y);
}
// Remove dialog
public void cleanUp() {
if (modalDialog != null)
modalDialog.dispose();
}
public static void main(String s[]) {
ModalDialogDisplayer displayer = new ModalDialogDisplayer();
theFrame.add("Center", displayer);
theFrame.pack();
theFrame.setSize(500, 300);
theFrame.show();
theFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
if (modalDialog != null)
modalDialog.dispose();
theFrame.dispose();
System.exit(0);
}
public void windowClosed(WindowEvent e) {
if (modalDialog != null)
modalDialog.dispose();
theFrame.dispose();
}
});
}
public void start() {}
public void stop() {}
public void destroy() {}
}
- duplicates
-
JDK-4080936 Components don't inherit parent container's background color
-
- Closed
-