-
Bug
-
Resolution: Fixed
-
P5
-
5.0
-
b13
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600],
Linux pbtmrte001 2.4.21-9.ELsmp #1 SMP Thu Jan 8 17:08:56 EST 2004 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
API specification says about installDefaults of BasicTextUI :
" The font, foreground, and background properties are only set if their current value is either null or a UIResource, other properties are set if the current value is null. "
But really others propertis are set also if they are UIResource.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run (see "source code for an executable test case"):
java -Xbootclasspath/p:C:\tmp javax.swing.plaf.basic.InstallDefaultsTest
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
javax.swing.plaf.ColorUIResource[r=51,g=51,b=51]
javax.swing.plaf.ColorUIResource[r=1,g=2,b=3]
ACTUAL -
javax.swing.plaf.ColorUIResource[r=51,g=51,b=51]
javax.swing.plaf.ColorUIResource[r=51,g=51,b=51]
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package javax.swing.plaf.basic;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.plaf.ColorUIResource;
public class InstallDefaultsTest extends JFrame {
static JTextField jtf;
public InstallDefaultsTest(){
super();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
jtf = new JTextField("test");
getContentPane().add(jtf);
setSize(200,200);
setVisible(true);
}
public static void main(String[] args) {
new InstallDefaultsTest();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run(){
System.out.println(jtf.getCaretColor());
jtf.setCaretColor(new ColorUIResource(1,2,3));
BasicTextUI ui = (BasicTextUI)jtf.getUI();
ui.installDefaults();
System.out.println(jtf.getCaretColor());
}
});
} catch (InvocationTargetException e){
} catch (InterruptedException e){}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Improve documentation.
###@###.### 2005-04-07 10:51:05 GMT
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600],
Linux pbtmrte001 2.4.21-9.ELsmp #1 SMP Thu Jan 8 17:08:56 EST 2004 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
API specification says about installDefaults of BasicTextUI :
" The font, foreground, and background properties are only set if their current value is either null or a UIResource, other properties are set if the current value is null. "
But really others propertis are set also if they are UIResource.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run (see "source code for an executable test case"):
java -Xbootclasspath/p:C:\tmp javax.swing.plaf.basic.InstallDefaultsTest
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
javax.swing.plaf.ColorUIResource[r=51,g=51,b=51]
javax.swing.plaf.ColorUIResource[r=1,g=2,b=3]
ACTUAL -
javax.swing.plaf.ColorUIResource[r=51,g=51,b=51]
javax.swing.plaf.ColorUIResource[r=51,g=51,b=51]
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package javax.swing.plaf.basic;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.plaf.ColorUIResource;
public class InstallDefaultsTest extends JFrame {
static JTextField jtf;
public InstallDefaultsTest(){
super();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
jtf = new JTextField("test");
getContentPane().add(jtf);
setSize(200,200);
setVisible(true);
}
public static void main(String[] args) {
new InstallDefaultsTest();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run(){
System.out.println(jtf.getCaretColor());
jtf.setCaretColor(new ColorUIResource(1,2,3));
BasicTextUI ui = (BasicTextUI)jtf.getUI();
ui.installDefaults();
System.out.println(jtf.getCaretColor());
}
});
} catch (InvocationTargetException e){
} catch (InterruptedException e){}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Improve documentation.
###@###.### 2005-04-07 10:51:05 GMT
- csr for
-
JDK-8263335 BasicTextUI: installDefaults method are contrary to the documentation
- Closed