1

I have some code where I'm showing up a dialog with two textboxes and two buttons (as OK, and Cancel, typical login window). The execution of the main code after the ".setVisible(true)" is conditioned to the values entered on that modal window.

The problem that I'm facing now is that if I do something like this:

        WindowInterceptor.init(new Trigger() {
            @Override
            public void run() throws Exception {
                LoginModal loginWin=new LoginModal();
                loginWin.setVisible(true);
                if(loginWin.getPassword().equals("any")) {
                    System.out.println("password OK!");
                }
            }
        }).process(new WindowHandler() {
            @Override
            public Trigger process(Window window) {
                System.out.println("triggered!");
            }
        }).run();

Then, the password would never be ok, because the handler is not called until the trigger is not finished. I'd expect it to get called when I call the setVisible(true), because otherwise, I can't run my "trigger" based on something entered by the window handler.

What is the correct approach to test this?

Thanks!

lqbweb
  • 1,684
  • 3
  • 19
  • 33

1 Answers1

2

This seems to be a problem with UISpec4J and Java 1.6u38, with 1.6u37 it works fine.

For example, with this simple code:

    WindowInterceptor.init(new Trigger() {

        @Override
        public void run() throws Exception {
            String myValue=JOptionPane.showInputDialog("thisssss");
            System.out.println("value " + myValue);
        }
    }).process(new WindowHandler() {
        @Override
        public Trigger process(Window window) {
            System.out.println("tal tal");
            return null
        }
    }).run();

myValue is always null, and my handler never triggered. Again, in 1.6u37 it works fine.

lqbweb
  • 1,684
  • 3
  • 19
  • 33
  • 1
    Seems to be that at that point the JRE starts checking the isModalityTypeSupported method of the toolkit in JDialog(Frame, bool), and UISpec4J always returns false, so your dialog never gets created modal. – Pete Feb 28 '14 at 17:47