Java SWT从按钮刷新多个壳 [英] Java SWT Refresh Multiple Shells From Button

查看:171
本文介绍了Java SWT从按钮刷新多个壳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个访问数据库的应用程序,目前我有一个显示主表的SWT Shell。从该表中,用户可以打开单个记录,并且从记录表单内部,用户可以打开具有相同类型但包含不同数据的第二个表单。
如果更新任一表单中的记录,则更新将反映在主表单中。
我的问题是我无法更新打开的第一个记录表单。
有没有办法强制更新或重绘某种类型的所有打开表单,或者有一种方法可以同时更新同一类型的多个shell。
下面的屏幕截图显示了我想要做的事情。

I am building an app that accesses a database and currently I have a SWT Shell that displays the main table. From this table users can open individual records and from inside the records form the user can open a second form that is of the same type but contains different data. If the record in either form is updated the update is reflected in the main form. My problem is I can't update the first record form that is opened. Is there a way to force an update or redraw for all open forms of a certain type or is there a way I can update multiple shell of the same type at the same time. The screen shot below shows what I am trying to do.

屏幕截图详情


  • A


    • 主表单

    • 当2个辅助表单中的任何一个更改数据库中的数据时,此表单当前会更新。这是通过从辅助表格重新加载表来完成的。


    • 这是数据表格的第一个实例


    • 这是第二个数据表单的实例。

    • 通过单击打开按钮从第一个数据表单打开它。我想要做的是在第二种形式更改内容时刷新第一个数据表单。

    • 例如,我打开了标签295 White的记录,当我更新数据时对于此记录,我希望更改显示在记录表格中26白色

    我知道这是一个难以理解的问题,所以请随时询问更多详细信息我正在试图解决这个问题。

    I know this is a hard to understand question, so feel free to ask for more details I am pulling my hair out trying to figure this out.

    推荐答案

    在主窗体中,您设置了一个Java Stack

    In the main form, you set up a Java Stack.

    Stack<DataForm> stack = new Stack<DataForm>(); 
    

    您将此 Stack 的引用传递给数据表格。

    You pass a reference of this Stack to the data form(s).

    在数据表单的构造函数中,您传递数据表单实例。

    In the constructor of the data form, you pass the data form instance.

    stack.push(this);
    

    在数据表单的析构函数中(退出时),删除数据表单实例。

    In the destructor of the data form (on exit), you remove the data form instance.

    int pos = stack.search(this);
    stack.remove(pos);
    

    当你想要刷新所有表格时,你会遍历堆栈。

    When you want to refresh all of the forms, you loop through the stack.

    for (DataForm dataForm : stack) {
         // do the refresh
    }
    

    这篇关于Java SWT从按钮刷新多个壳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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