如何让按钮自己执行或者在一个按钮之后  启动另外一个按钮  在swt中写的 robot   swt有类似robot的类吗 按钮1 执行完毕之后 自动执行按钮2失败的经验:1,把按钮2里面的方法放到按钮1里面  有可能是因为有js语句的原因   行不通。
            2,在方法之间放入sleep();也不可以   只执行最后一个js语句

解决方案 »

  1.   

    用JButton的JButton.doClick()方法就可以模拟按下按钮。
      

  2.   

    i don't know currently.
      

  3.   

    这个问题。
    有A、B2个按钮 对应的事件为A.action(XXX)、B.action(XXX)
    如果点击A 却像执行A、B 2个的事件 那就把B的事件放到A的事件里就可以了。。
    改为A.action(XXX;B.action())
      

  4.   

    我没有用过swt,刚才看了一下api
    你看下面这个方法行不行。
    Abutton的 
    on action do 里面调用Bbutton的notifyListeners方法。
    notifyListeners
    org.eclipse.swt.widgets
    Class Widget
    public void notifyListeners(int eventType,
                                Event event)
        Notifies all of the receiver's listeners for events of the given type that one such event has occurred by invoking their handleEvent() method. The event type is one of the event constants defined in class SWT.
        Parameters:
            eventType - the type of event which has occurred
            event - the event data 
        Throws:
            SWTException -
                * ERROR_WIDGET_DISPOSED - if the receiver has been disposed
                * ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    我觉得应该可以的。
      

  5.   


    如果你描述的问题,只是想触发button的click事件的话,notify这套方法就够了
    不过,我觉得notify的话,和你直接调用方法,其实没什么大区别关键是你到底遇到了什么问题
    你上面说嵌入了js,你是怎么嵌入的
      

  6.   

    我也是觉得楼主没有描述清楚,swt里面嵌入js??要执行a的button响应完了执行Button b的响应,那么把b的代码放a的响应中处理即可,不可以的原因肯定是其他代码导致的,你可以把这两段代码贴一下;
    另:在swt中也是可以使用awt Robot的
      

  7.   


    js的问题我已经解决了 用api的一个方法  现在的问题就是 《如何触发button的click事件》
      

  8.   

    呵呵  我的描述是有一点问题  我发现了  如果button方法里面 有多个js语句  它只执行最后一个语句 (我已经找到一个broswer方法解决了)现在就是想在swt里面  “按钮1里面的方法执行完毕之后 自动执行按钮2 (不要把按钮2的方法 放到按钮1里面)”                                                                          真实的发生Click时间 (类似swing的doclick)
      

  9.   

    那就是new一个event,然后给按钮2notify一下就行了
      

  10.   

    notify 好好学吧 孩子 这个方法肯定能行