Dear Les,

thanks a lot for your thorough analysis.
This is indeed a bug which occurs in conjunction with JDK 1.5.
Not that it does not occur in conjunction with JDK 1.4, because
the Windows look&feel has slightly changed in the meantime.
I opened a bug report for this (UBA-6952).

Here is a fix for your example. It provides two fixing extension
of ULCTextField and ULCPasswordField, respectively.

Greetings and thanks a lot for you input,

Daniel


public class ULCDisableTest extends AbstractApplication {
    public void start() {
        ULCFrame frame = new ULCFrame("ULC Disable Test");
        ULCBorderLayoutPane pane = new ULCBorderLayoutPane();

        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);

        pane.add(createTestPane(), ULCBorderLayoutPane.CENTER);
        frame.add(pane);
        frame.pack();
        frame.setVisible(true);
    }

    private ULCBoxPane createTestPane() {
        ULCBoxPane pane = new ULCBoxPane();
        pane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));

        ULCCheckBox checkBox = new ULCCheckBox("Test Disabled State");
        ULCComboBox combo = new ULCComboBox(createTestComboBoxModel());
        combo.setEnabler(checkBox);
        ULCTextField name = new ULCTextFieldFix(20);
        name.setText("test");
        name.setEnabler(checkBox);
        ULCPasswordField pass = new ULCPasswordFieldFix(20);
        pass.setEnabler(checkBox);

        pane.add(ULCBoxPane.BOX_LEFT_CENTER, checkBox);
        pane.add(ULCBoxPane.BOX_LEFT_CENTER, combo);
        pane.add(ULCBoxPane.BOX_LEFT_CENTER, name);
        pane.add(ULCBoxPane.BOX_LEFT_CENTER, pass);

        return pane;
    }

    private DefaultComboBoxModel createTestComboBoxModel() {
        List testList = new ArrayList();
        testList.add("one");
        testList.add("two");
        testList.add("three");

        return new DefaultComboBoxModel(testList.toArray());
    }

    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName
());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        DevelopmentRunner.setApplicationClass(ULCDisableTest.class);
        DevelopmentRunner.run();
    }

    public static class ULCTextFieldFix extends ULCTextField {
        public ULCTextFieldFix() {
            super();
        }

        public ULCTextFieldFix(int columns) {
            super(columns);
        }

        public ULCTextFieldFix(String text, int columns) {
            super(text, columns);
        }

        public ULCTextFieldFix(String text) {
            super(text);
        }

        protected String typeString() {
            return UITextFieldFix.class.getName();
        }
    }

    public static class UITextFieldFix extends UITextField {
        protected void switchBackgroundColor() {
        }
    }

    public static class ULCPasswordFieldFix extends ULCPasswordField {
        public ULCPasswordFieldFix() {
            super();
        }

        public ULCPasswordFieldFix(int columns) {
            super(columns);
        }

        public ULCPasswordFieldFix(String text, int columns) {
            super(text, columns);
        }

        public ULCPasswordFieldFix(String text) {
            super(text);
        }

        protected String typeString() {
            return UIPasswordFieldFix.class.getName();
        }
    }

    public static class UIPasswordFieldFix extends UIPasswordField {
        protected void switchBackgroundColor() {
        }
    }
}


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Les Thomas
Sent: Donnerstag, 13. Juli 2006 00:56
To: [EMAIL PROTECTED]
Cc: 'Les Thomas'
Subject: [ULC-developer] Initial disabled state look and feel issue


I believe I have found a bug when setting the enabled state to false for a
ULCTextField and ULCPasswordField using the Windows look and feel.  I have
included screen shots as well as test cases.  For the test cases, I have
provided equivalent ULC and Swing implementations to see whether this was a
Swing bug or ULC bug.
Perhaps there is something special I need to do in the ULC case, but I wasn'
t able to find the setting to get around this issue.

Here are the details:

When you setEnabled(false) for ULCTextField and ULCPasswordField, the
disabled background color is not initially set.  The fields are correctly
disabled so that the user cannot input into them, but the background color
is white, which implies input capability is allowed.   Please note that this
behavior does not occur when using equivalent swing widgets.

See screen shots:
swing_disable_initial_step.jpg - this shows the initial state using Swing
widgets. Notice the background color used to show disable state is correct.
ulc_disable_initial_step.jpg - this shows the initial state using equivalent
ULC widgets. Notice the background color is incorrect (ie, it didn't change
and it is still white).
ulc_disable_after_state_change.jpg - this shows the results after recycling
the state (ie, selected the checkbox and then unselected it).  The checkbox
is used to enable and disable the ULCTextField and ULCPasswordField's.  Note
that the background color is now correctly set to show a disabled state.

This is an important look and feel issue since the initial state shown in
ULC implies that the field is enabled, when in fact it isn't.  Please note
that is only happens when running on Windows and setting the look and feel
using UIManager.getSystemLookAndFeelClassName().  If the default Metal Look
and Feel is used, the disabled background color is initially correctly set.

Kind regards,

Les

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to