如何在java中使用swing在gui应用程序上设计的textarea中显示cmd的运行注释

如何在java中使用swing在gui应用程序上设计的textarea中显示cmd的运行注释,java,swing,Java,Swing,在使用java中的swing从gui应用程序运行一个可执行文件之后, 我想在我的文本区域中显示cmd的运行注释,我已经在下半部分使用了gui应用程序。我该怎么做呢。 这是我为运行.exe文件的运行按钮编写的代码:- private void runActionPerformed(java.awt.event.ActionEvent evt) { System.out.println( "Running" );

在使用java中的swing从gui应用程序运行一个可执行文件之后, 我想在我的文本区域中显示cmd的运行注释,我已经在下半部分使用了gui应用程序。我该怎么做呢。 这是我为运行.exe文件的运行按钮编写的代码:-

private void runActionPerformed(java.awt.event.ActionEvent evt) {                                    
        System.out.println( "Running" );
        try
        {
            String [] command    = { "cmd.exe", "/c", "start",
                                     "runMatness.bat",
                                     "inputfile=" + myFilePath,
                                     "dbreporting=false" };
            Process myProcess    = Runtime.getRuntime().exec(command);
            BufferedReader input =
            new BufferedReader (new InputStreamReader(myProcess.getInputStream()));
            while ((line = input.readLine()) != null)
            {
                displayresult.append(line);
            }//while
            input.close();
        }// eof try
        catch (Exception err)
        {
            err.printStackTrace();
        }//eof catch
其中displayresult是我的文本区域。

请确保每次

displayresult.append(line);
致电:

java.awt.Container#validate()
封闭容器的方法。容器是接收displayresult的组件:

someContainer.add(displayresult);
每过一天一定要去

displayresult.append(line);
致电:

java.awt.Container#validate()
封闭容器的方法。容器是接收displayresult的组件:

someContainer.add(displayresult);