Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6251901
Votes 0
Synopsis BasicTextUI: installDefaults method are contrary to the documentation
Category java:classes_swing
Reported Against
Release Fixed
State 3-Accepted, bug
Priority: 5-Very Low
Related Bugs
Submit Date 07-APR-2005
Description
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 :
 customer  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.
  xxxxx@xxxxx   2005-04-07 10:51:05 GMT
Work Around
N/A
Evaluation
Contribution forum : https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=13511
Posted Date : 2006-06-08 21:21:03.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang