-
Bug
-
Resolution: Fixed
-
P4
-
6
A DESCRIPTION OF THE REGRESSION :
In a textfield, under certain circumstances i like to change the background color to GREEN. And when the circumstances are not true anymore, I would like to restore the color back to what it was at the beginning ( ie default ).
I can set the color to what looks like green. BUT i cannot restore the color back to the original background color. Its close, but does not match.
REPRODUCIBLE TESTCASE OR STEPS TO REPRODUCE:
/* run program. hit green button. hit default button.
* BTW if you change the AWT_TOOLKIT=MToolkit environement setting it behaves
*/
/*
* NewFrame.java
*
* Created on February 13, 2006, 4:29 PM
*/
package whereismybackground;
/**
*
* @author gat
*/
import java.awt.Color;
public class NewFrame extends java.awt.Frame {
Color backGroundColor;
/** Creates new form NewFrame */
public NewFrame() {
initComponents();
backGroundColor = textField1.getBackground();
}
/** 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 ">//GEN-BEGIN:initComponents
private void initComponents() {
panel1 = new java.awt.Panel();
textField1 = new java.awt.TextField();
textField2 = new java.awt.TextField();
panel2 = new java.awt.Panel();
panel3 = new java.awt.Panel();
greenButton = new java.awt.Button();
defaultButton = new java.awt.Button();
quitButton = new java.awt.Button();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
textField1.setEditable(false);
textField1.setFont(new java.awt.Font("Dialog", 0, 36));
textField1.setText("textField1");
panel1.add(textField1);
textField2.setEditable(false);
textField2.setFont(new java.awt.Font("Dialog", 0, 36));
textField2.setText("textField2");
panel1.add(textField2);
add(panel1, java.awt.BorderLayout.NORTH);
add(panel2, java.awt.BorderLayout.CENTER);
greenButton.setLabel("Green");
greenButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
greenButtonMouseClicked(evt);
}
});
panel3.add(greenButton);
defaultButton.setLabel("Default");
defaultButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
defaultButtonMouseClicked(evt);
}
});
panel3.add(defaultButton);
quitButton.setLabel("quit");
quitButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
quitButtonMouseClicked(evt);
}
});
panel3.add(quitButton);
add(panel3, java.awt.BorderLayout.SOUTH);
pack();
}
// </editor-fold>//GEN-END:initComponents
private void quitButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_quitButtonMouseClicked
// TODO add your handling code here:
exitForm( null );
}//GEN-LAST:event_quitButtonMouseClicked
private void defaultButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_defaultButtonMouseClicked
// TODO add your handling code here:
if ( textField1.getBackground().equals( Color.GREEN )) {
textField1.setBackground( backGroundColor );
//textField2.setBackground( backGroundColor );
}
}//GEN-LAST:event_defaultButtonMouseClicked
private void greenButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_greenButtonMouseClicked
// TODO add your handling code here:
if ( textField1.getBackground().equals( Color.GREEN ) == false ) {
textField1.setBackground( Color.GREEN );
//textField2.setBackground( Color.GREEN );
}
}//GEN-LAST:event_greenButtonMouseClicked
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit(0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private java.awt.Button defaultButton;
private java.awt.Button greenButton;
private java.awt.Panel panel1;
private java.awt.Panel panel2;
private java.awt.Panel panel3;
private java.awt.Button quitButton;
private java.awt.TextField textField1;
private java.awt.TextField textField2;
// End of variables declaration//GEN-END:variables
}
RELEASE LAST WORKED:
5.0
RELEASE TEST FAILS:
mustang-b70
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
i expected the background color to be restored.
ACTUAL -
When default background color is restored, its just not the same as when the textfield was first created.
OBSERVED APPLICATION IMPACT:
probably not much impact. After all such differences in background color have already been relegated to the "will not be fixed" category of bug and conformal standards, much to the fustration of developers.
In a textfield, under certain circumstances i like to change the background color to GREEN. And when the circumstances are not true anymore, I would like to restore the color back to what it was at the beginning ( ie default ).
I can set the color to what looks like green. BUT i cannot restore the color back to the original background color. Its close, but does not match.
REPRODUCIBLE TESTCASE OR STEPS TO REPRODUCE:
/* run program. hit green button. hit default button.
* BTW if you change the AWT_TOOLKIT=MToolkit environement setting it behaves
*/
/*
* NewFrame.java
*
* Created on February 13, 2006, 4:29 PM
*/
package whereismybackground;
/**
*
* @author gat
*/
import java.awt.Color;
public class NewFrame extends java.awt.Frame {
Color backGroundColor;
/** Creates new form NewFrame */
public NewFrame() {
initComponents();
backGroundColor = textField1.getBackground();
}
/** 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 ">//GEN-BEGIN:initComponents
private void initComponents() {
panel1 = new java.awt.Panel();
textField1 = new java.awt.TextField();
textField2 = new java.awt.TextField();
panel2 = new java.awt.Panel();
panel3 = new java.awt.Panel();
greenButton = new java.awt.Button();
defaultButton = new java.awt.Button();
quitButton = new java.awt.Button();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
textField1.setEditable(false);
textField1.setFont(new java.awt.Font("Dialog", 0, 36));
textField1.setText("textField1");
panel1.add(textField1);
textField2.setEditable(false);
textField2.setFont(new java.awt.Font("Dialog", 0, 36));
textField2.setText("textField2");
panel1.add(textField2);
add(panel1, java.awt.BorderLayout.NORTH);
add(panel2, java.awt.BorderLayout.CENTER);
greenButton.setLabel("Green");
greenButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
greenButtonMouseClicked(evt);
}
});
panel3.add(greenButton);
defaultButton.setLabel("Default");
defaultButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
defaultButtonMouseClicked(evt);
}
});
panel3.add(defaultButton);
quitButton.setLabel("quit");
quitButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
quitButtonMouseClicked(evt);
}
});
panel3.add(quitButton);
add(panel3, java.awt.BorderLayout.SOUTH);
pack();
}
// </editor-fold>//GEN-END:initComponents
private void quitButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_quitButtonMouseClicked
// TODO add your handling code here:
exitForm( null );
}//GEN-LAST:event_quitButtonMouseClicked
private void defaultButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_defaultButtonMouseClicked
// TODO add your handling code here:
if ( textField1.getBackground().equals( Color.GREEN )) {
textField1.setBackground( backGroundColor );
//textField2.setBackground( backGroundColor );
}
}//GEN-LAST:event_defaultButtonMouseClicked
private void greenButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_greenButtonMouseClicked
// TODO add your handling code here:
if ( textField1.getBackground().equals( Color.GREEN ) == false ) {
textField1.setBackground( Color.GREEN );
//textField2.setBackground( Color.GREEN );
}
}//GEN-LAST:event_greenButtonMouseClicked
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit(0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private java.awt.Button defaultButton;
private java.awt.Button greenButton;
private java.awt.Panel panel1;
private java.awt.Panel panel2;
private java.awt.Panel panel3;
private java.awt.Button quitButton;
private java.awt.TextField textField1;
private java.awt.TextField textField2;
// End of variables declaration//GEN-END:variables
}
RELEASE LAST WORKED:
5.0
RELEASE TEST FAILS:
mustang-b70
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
i expected the background color to be restored.
ACTUAL -
When default background color is restored, its just not the same as when the textfield was first created.
OBSERVED APPLICATION IMPACT:
probably not much impact. After all such differences in background color have already been relegated to the "will not be fixed" category of bug and conformal standards, much to the fustration of developers.
- duplicates
-
JDK-6385859 Textfield.setBackground() fails to restore default background
- Closed
- relates to
-
JDK-5092883 REGRESSION: SystemColor class gives back wrong values under Linux
- Resolved