UISpec4J在触发完成之前捕获模式对话框 [英] UISpec4J Capturing modal dialog, before the trigger finish

查看:53
本文介绍了UISpec4J在触发完成之前捕获模式对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码,其中显示了一个带有两个文本框和两个按钮的对话框(如确定"和取消",即典型的登录窗口).在".setVisible(true)"之后执行主代码的条件取决于在该模式窗口中输入的值.

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();

然后,密码将永远不会确定,因为直到触发器未完成才调用处理程序.我希望在调用setVisible(true)时会调用它,因为否则,我将无法基于窗口处理程序输入的内容来运行触发器".

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?

谢谢!

推荐答案

这似乎是UISpec4J和Java 1.6u38的问题,而1.6u37可以正常工作.

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始终为null,并且我的处理程序从未触发.同样,在1.6u37中它可以正常工作.

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

这篇关于UISpec4J在触发完成之前捕获模式对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆