Hi, Janak!

Unfortunately this workaround doesn't work!
I still see "ok" button selected by default not "cancel" one!

 
~~~~~~~~~~~~~~~~~~~~~~
Vitaliy Tkachenko
Senior Software Engineer
Mirasoft
 
E-mail: [EMAIL PROTECTED]
Work phone: +380 44 4929960
Cellular phone: +380 66 7406009
ICQ: 40299155
Skype: virtualvat
 

-----Original Message-----
From: Janak Mulani (JIRA) [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 08, 2007 3:27 PM
To: Vitaliy Tkachenko
Subject: [JIRA] Commented: (UBA-7154) ULCAlert.setInitialValue doesn't
work

    [
https://www.canoo.com/jira/browse/UBA-7154?page=comments#action_10740 ] 
            
Janak Mulani commented on UBA-7154:
-----------------------------------

This is a Swing bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6176477.

For a work around see the snippet below. To reproduce the error, in the
snippet, replace MyULCAlert  with ULCAlert


import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;

import com.ulcjava.base.application.AbstractAction;
import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ULCAlert;
import com.ulcjava.base.application.ULCBorderLayoutPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCRootPane;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.IWindowListener;
import com.ulcjava.base.client.UIAlert;
import com.ulcjava.base.development.DevelopmentRunner;

public class PR7154 extends AbstractApplication {
    public void start() {

        ULCFrame frame = new ULCFrame("ULCTableFocusGainedSnippet");
        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
        frame.getContentPane().add(new ULCButton(new ClickMeAction()),
ULCBorderLayoutPane.CENTER);
        frame.setSize(100, 100);
        frame.setVisible(true);
    }

    public static void main(String[] args) {

        try {
            // LookAndFeel laf = new
javax.swing.plaf.metal.MetalLookAndFeel();
            // LookAndFeel laf = new
com.sun.java.swing.plaf.motif.MotifLookAndFeel();
            LookAndFeel laf = new
com.sun.java.swing.plaf.windows.WindowsLookAndFeel();

            UIManager.setLookAndFeel(laf);
        } catch (Exception e) {
            e.printStackTrace();
        }

        DevelopmentRunner.setApplicationClass(PR7154.class);
        DevelopmentRunner.main(args);
    }

    private static class ClickMeAction extends AbstractAction {
        public ClickMeAction() {
            putValue(NAME, "Show Alert");
        }

        public void actionPerformed(ActionEvent event) {
            final ULCAlert dialog = new MyULCAlert((ULCRootPane) null,
"Test title", "Test message", null);
            dialog.setFirstButtonLabel("Ok");
            dialog.setSecondButtonLabel("Cancel");
            dialog.setInitialValue("Cancel");
            dialog.addWindowListener(new IWindowListener() {

                public void
windowClosing(com.ulcjava.base.application.event.WindowEvent event) {
                    System.out.println(dialog.getValue());
                }

            });
            dialog.show();

        }
    }

    public static class MyULCAlert extends ULCAlert {

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

        public MyULCAlert(ULCRootPane pane, String title, String
message, String firstButtonLabel) {
            super(pane, title, message, firstButtonLabel);
        }

    }

    public static class MyUIAlert extends UIAlert {

        protected void prepareAlertDialog(final JDialog dialog) {
            dialog.addWindowListener(new WindowListener() {

                public void windowActivated(WindowEvent e) {
                }

                public void windowClosed(WindowEvent e) {
                }

                public void windowClosing(WindowEvent e) {
                }

                public void windowDeactivated(WindowEvent e) {
                }

                public void windowDeiconified(WindowEvent e) {
                }

                public void windowIconified(WindowEvent e) {
                }

                public void windowOpened(WindowEvent e) {
                    JOptionPane optionPane = (JOptionPane)
dialog.getContentPane().getComponent(0);
                    optionPane.selectInitialValue();
                }

            });
        }

    }
}

> ULCAlert.setInitialValue doesn't work
> -------------------------------------
>
>                 Key: UBA-7154
>                 URL: https://www.canoo.com/jira/browse/UBA-7154
>             Project: ULCBase
>          Issue Type: Bug
>          Components: core
>    Affects Versions: ULC 6.1.1
>         Environment: Windows XP
>            Reporter: Vitaliy Tkachenko
>         Assigned To: ULC Team
>
> setInitialValue is not working!
> ====================
>               ULCAlert dialog = new ULCAlert((ULCRootPane)null, "Test
title", "Test message", null);
>               dialog.setFirstButtonLabel("Ok");
>               dialog.setSecondButtonLabel("Cancel");
>               dialog.setInitialValue("Cancel");
>               dialog.show();
> ====================
> this code results with the "Ok" button focused by default.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://www.canoo.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira

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

Reply via email to