FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b70)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b70, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
linux Fedord 4
Linux MyLaptop.gatworks.com 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
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.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run sample. hit green button. hit default button.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
i expected the default background color to be set for textfield.
ACTUAL -
a close color is substituted.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* 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
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None.
java version "1.6.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b70)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b70, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
linux Fedord 4
Linux MyLaptop.gatworks.com 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
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.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run sample. hit green button. hit default button.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
i expected the default background color to be set for textfield.
ACTUAL -
a close color is substituted.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* 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
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None.
- duplicates
-
JDK-6386986 REGRESSION: unable to change back to default background color on a textfield.
- Resolved
- relates to
-
JDK-5092883 REGRESSION: SystemColor class gives back wrong values under Linux
- Resolved