-
Bug
-
Resolution: Fixed
-
P4
-
1.1.6
-
kestrel
-
x86
-
windows_95
Name: skT88420 Date: 08/16/99
java.awt.TextComponent does not use SystemColor.window
as the background color when specified on Windows 95/NT.
To reproduce this problem, you must set your Windows
Display colors so that a non-White color is used for
"Window Text". For example, if you set your "Window Text"
color to be gray, and run the example application below,
you will see that the java.awt.Label's will have a
gray background, but the TextField and TextArea will
have a white background.
import java.applet.*;
import java.awt.*;
/**
* This applet was generated by a SmartGuide.
*
*/
public class TextColorsTest extends Applet {
private Label ivjLabel = null;
private Label ivjLabel1 = null;
private Label ivjLabel2 = null;
private Label ivjLabel3 = null;
private Label ivjLabel4 = null;
private TextArea ivjTextArea1 = null;
private TextField ivjTextField1 = null;
/**
* Gets the applet information.
* @return java.lang.String
*/
public String getAppletInfo() {
return "TextColorsTest created using VisualAge for Java.";
}
/**
* Return the Label property value.
* @return java.awt.Label
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private Label getLabel() {
if (ivjLabel == null) {
try {
ivjLabel = new java.awt.Label();
ivjLabel.setName("Label");
ivjLabel.setText("This Label is SystemColor.window(Text)");
ivjLabel.setBackground(java.awt.SystemColor.window);
ivjLabel.setForeground(java.awt.SystemColor.windowText);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjLabel;
}
/**
* Return the Label1 property value.
* @return java.awt.Label
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private Label getLabel1() {
if (ivjLabel1 == null) {
try {
ivjLabel1 = new java.awt.Label();
ivjLabel1.setName("Label1");
ivjLabel1.setAlignment(java.awt.Label.CENTER);
ivjLabel1.setText("Background Color = SystemColor.control");
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjLabel1;
}
/**
* Return the Label2 property value.
* @return java.awt.Label
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private Label getLabel2() {
if (ivjLabel2 == null) {
try {
ivjLabel2 = new java.awt.Label();
ivjLabel2.setName("Label2");
ivjLabel2.setText("This Label is SystemColor.window(Text)");
ivjLabel2.setBackground(java.awt.SystemColor.window);
ivjLabel2.setForeground(java.awt.SystemColor.windowText);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjLabel2;
}
/**
* Return the Label3 property value.
* @return java.awt.Label
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private Label getLabel3() {
if (ivjLabel3 == null) {
try {
ivjLabel3 = new java.awt.Label();
ivjLabel3.setName("Label3");
ivjLabel3.setAlignment(java.awt.Label.LEFT);
ivjLabel3.setText("Do the Label and TextField/TextArea colors match?");
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjLabel3;
}
/**
* Return the Label4 property value.
* @return java.awt.Label
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private Label getLabel4() {
if (ivjLabel4 == null) {
try {
ivjLabel4 = new java.awt.Label();
ivjLabel4.setName("Label4");
ivjLabel4.setAlignment(java.awt.Label.CENTER);
ivjLabel4.setText("Foreground color = SystemColor.controlText");
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjLabel4;
}
/**
* Return the TextArea1 property value.
* @return java.awt.TextArea
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private TextArea getTextArea1() {
if (ivjTextArea1 == null) {
try {
ivjTextArea1 = new java.awt.TextArea();
ivjTextArea1.setName("TextArea1");
ivjTextArea1.setText("BG = SystemColor.window");
ivjTextArea1.setBackground(java.awt.SystemColor.window);
ivjTextArea1.setForeground(java.awt.SystemColor.windowText);
ivjTextArea1.setColumns(40);
ivjTextArea1.setRows(5);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjTextArea1;
}
/**
* Return the TextField1 property value.
* @return java.awt.TextField
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private TextField getTextField1() {
if (ivjTextField1 == null) {
try {
ivjTextField1 = new java.awt.TextField();
ivjTextField1.setName("TextField1");
ivjTextField1.setText("BG = SystemColor.window");
ivjTextField1.setBackground(java.awt.SystemColor.window);
ivjTextField1.setForeground(java.awt.SystemColor.windowText);
ivjTextField1.setColumns(40);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjTextField1;
}
/**
* Called whenever the part throws an exception.
* @param exception java.lang.Throwable
*/
private void handleException(Throwable exception) {
/* Uncomment the following lines to print uncaught exceptions to stdout */
// System.out.println("--------- UNCAUGHT EXCEPTION ---------");
// exception.printStackTrace(System.out);
}
/**
* Handle the Applet init method.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public void init() {
super.init();
try {
java.awt.GridBagConstraints constraintsLabel1 = new java.awt.GridBagConstraints();
java.awt.GridBagConstraints constraintsLabel2 = new java.awt.GridBagConstraints();
java.awt.GridBagConstraints constraintsLabel = new java.awt.GridBagConstraints();
java.awt.GridBagConstraints constraintsTextField1 = new java.awt.GridBagConstraints();
java.awt.GridBagConstraints constraintsTextArea1 = new java.awt.GridBagConstraints();
java.awt.GridBagConstraints constraintsLabel3 = new java.awt.GridBagConstraints();
java.awt.GridBagConstraints constraintsLabel4 = new java.awt.GridBagConstraints();
setName("TextColorsTest");
setLayout(new java.awt.GridBagLayout());
setBackground(java.awt.SystemColor.control);
setSize(611, 288);
setForeground(java.awt.SystemColor.controlText);
constraintsLabel1.gridx = 0; constraintsLabel1.gridy = 0;
constraintsLabel1.gridwidth = 2; constraintsLabel1.gridheight = 1;
constraintsLabel1.fill = java.awt.GridBagConstraints.HORIZONTAL;
constraintsLabel1.anchor = java.awt.GridBagConstraints.CENTER;
constraintsLabel1.weightx = 1.0;
constraintsLabel1.weighty = 0.0;
constraintsLabel1.insets = new java.awt.Insets(5, 5, 5, 5);
((java.awt.GridBagLayout) this.getLayout()).setConstraints(getLabel1(), constraintsLabel1);
this.add(getLabel1());
constraintsLabel2.gridx = 0; constraintsLabel2.gridy = 2;
constraintsLabel2.gridwidth = 1; constraintsLabel2.gridheight = 1;
constraintsLabel2.anchor = java.awt.GridBagConstraints.WEST;
constraintsLabel2.weightx = 0.0;
constraintsLabel2.weighty = 0.0;
constraintsLabel2.insets = new java.awt.Insets(5, 5, 0, 0);
((java.awt.GridBagLayout) this.getLayout()).setConstraints(getLabel2(), constraintsLabel2);
this.add(getLabel2());
constraintsLabel.gridx = 0; constraintsLabel.gridy = 3;
constraintsLabel.gridwidth = 1; constraintsLabel.gridheight = 1;
constraintsLabel.anchor = java.awt.GridBagConstraints.WEST;
constraintsLabel.weightx = 0.0;
constraintsLabel.weighty = 0.0;
constraintsLabel.insets = new java.awt.Insets(5, 5, 0, 0);
((java.awt.GridBagLayout) this.getLayout()).setConstraints(getLabel(), constraintsLabel);
this.add(getLabel());
constraintsTextField1.gridx = 1; constraintsTextField1.gridy = 2;
constraintsTextField1.gridwidth = 1; constraintsTextField1.gridheight = 1;
constraintsTextField1.anchor = java.awt.GridBagConstraints.WEST;
constraintsTextField1.weightx = 0.0;
constraintsTextField1.weighty = 0.0;
((java.awt.GridBagLayout) this.getLayout()).setConstraints(getTextField1(), constraintsTextField1);
this.add(getTextField1());
constraintsTextArea1.gridx = 1; constraintsTextArea1.gridy = 3;
constraintsTextArea1.gridwidth = 1; constraintsTextArea1.gridheight = 1;
constraintsTextArea1.anchor = java.awt.GridBagConstraints.WEST;
constraintsTextArea1.weightx = 0.0;
constraintsTextArea1.weighty = 0.0;
constraintsTextArea1.insets = new java.awt.Insets(5, 0, 0, 0);
((java.awt.GridBagLayout) this.getLayout()).setConstraints(getTextArea1(), constraintsTextArea1);
this.add(getTextArea1());
constraintsLabel3.gridx = 0; constraintsLabel3.gridy = 4;
constraintsLabel3.gridwidth = 2; constraintsLabel3.gridheight = 1;
constraintsLabel3.fill = java.awt.GridBagConstraints.BOTH;
constraintsLabel3.anchor = java.awt.GridBagConstraints.NORTH;
constraintsLabel3.weightx = 1.0;
constraintsLabel3.weighty = 1.0;
constraintsLabel3.insets = new java.awt.Insets(5, 5, 5, 5);
((java.awt.GridBagLayout) this.getLayout()).setConstraints(getLabel3(), constraintsLabel3);
this.add(getLabel3());
constraintsLabel4.gridx = 0; constraintsLabel4.gridy = 1;
constraintsLabel4.gridwidth = 2; constraintsLabel4.gridheight = 1;
constraintsLabel4.fill = java.awt.GridBagConstraints.HORIZONTAL;
constraintsLabel4.anchor = java.awt.GridBagConstraints.CENTER;
constraintsLabel4.weightx = 1.0;
constraintsLabel4.weighty = 0.0;
constraintsLabel4.insets = new java.awt.Insets(5, 5, 10, 5);
((java.awt.GridBagLayout) this.getLayout()).setConstraints(getLabel4(), constraintsLabel4);
this.add(getLabel4());
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
/**
* main entrypoint - starts the part when it is run as an application
* @param args java.lang.String[]
*/
public static void main(java.lang.String[] args) {
try {
java.awt.Frame frame;
try {
Class aFrameClass = Class.forName("uvm.abt.edit.TestFrame");
frame = (java.awt.Frame)aFrameClass.newInstance();
} catch (java.lang.Throwable ivjExc) {
frame = new java.awt.Frame();
}
TextColorsTest aTextColorsTest = new TextColorsTest();
frame.add("Center", aTextColorsTest);
frame.setSize(aTextColorsTest.getSize());
aTextColorsTest.init();
aTextColorsTest.start();
frame.setVisible(true);
aTextColorsTest.destroy();
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of java.applet.Applet");
}
}
(Review ID: 34912)
======================================================================