在TextArea上打印交易状态 [英] Print transaction status on TextArea

查看:117
本文介绍了在TextArea上打印交易状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个执行以下操作的项目:

I am developing a project which does the following :

1。截断一个临时表T1。

1.truncate a temporary table T1.

2。在临时表T1中插入几千行。

2.insert some thousand rows into temporary table T1.

3。执行一个有一定提交的过程

3.Execute a procedure which has some commit statements in it.

4。将行从表T1插入到其他相同的表(就结构而言)T2

4.insert rows from table T1 to other identical table(with respect to structure) T2

5。再执行2个过程。

5.Execute 2 more procedures.

现在,我已经创建了一个摆动UI,其中包含要打印交易状态的TextArea。像这样的

Now i have made a swing UI which contains TextArea on which i want to print transaction status. Something like this

读取Excel文件..
验证Excel文件..
将条目插入表T1 ..,依此类推

Reading Excel File.. Validating Excel File.. inserting entries into table T1.. and so on

我已经通过以下方法在每个步骤中更新状态。

I have made the following method to update status at each step.

public void updateStatus(String message){
        String temp = this.statusText.getText();
        this.statusText.setText(temp  + message +  "\n");
}

调用此方法以及我在其中执行的语句

Calling this method along with statements where i do

log.debug(message)替我完成了工作!但是,这使我的代码设计复杂化。现在,每个DAO组件都依赖于此方法。谁能建议我一个更好的设计方案。

log.debug(message) does the job for me ! However this complicates my code design. Every DAO Component now depends on this method. Can anyone suggest me a better design option.

在此先感谢!

推荐答案


log.debug(message)为我完成了工作!但是,这会使我的
代码设计变得复杂。现在,每个DAO组件都依赖于此方法。
谁能建议我一个更好的设计方案。

log.debug(message) does the job for me ! However this complicates my code design. Every DAO Component now depends on this method. Can anyone suggest me a better design option.




  • 您遇到了问题与 Swing的一致性,包装statusText.append(message + \n);到 invokeLater

    • you have an issue with Concurency in Swing, wrap statusText.append(message + "\n"); to invokeLater,

      Swing是单线程的,并且对已经可见的Swing GUi的所有更新都必须是在事件调度线程

      Swing is single threaded, and all updates to the already visible Swing GUi must be done on Event Dispatch Thread

      也许您可以查看 SwingWorker ,从发布的说明中看不出来,只有那可能是长期的,艰难的,谈论EDT问题。

      maybe you can look at SwingWorker, nothing clear from posted description, only that could be hard and long running, talking about EDT issue

      减少处理器消耗并使用适当的方法进行处理将新的 String 附加到已经可见的 JTextArea ,请使用 statusText.append(message + \ \n); 而不是相当困难

      reduce procesors consuption and to use proper methods for appending a new String to already visible JTextArea, use statusText.append(message + "\n"); instead of quite hard

      String temp = this.statusText.getText(); // take all string from JTextArea
      this.statusText.setText(temp  + message +  "\n"); // append() a new line to 
      

      这篇关于在TextArea上打印交易状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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