Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
我有一个采用参数的JFrame,然后将其发送到Java进程,并且有一个标签给出未运行或正在运行的状态,因此,当调用按钮时,它将更改标签,然后使用该进程调用该函数,该进程正在调用命令行上的MatLab可执行程序,问题是当流程功能不起作用时,标签会更新正常,但当它起作用时,标签将不会更新。我已经尝试过重新绘制和重新验证的每种组合,我认为可能,我也尝试过使用SwingUtilities.InvokeLater()来调用更新测试或我正在调用的函数,或者两者都调用
这就是我设置标签的方式。 ''' update = new JLabel(); update.setText("Status: Not Running"); '''这是调用更新的按钮。 ''' run.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent w) { update.setText("Status: Running"); update.revalidate(); update.repaint(); repaint(); revalidate(); DIP(); } }); ''' 以防万一这是DIP功能 ''' private void DIP() { File ff = new File(outputFile + "\\Output_Data\\"); if (ff.isDirectory()) ff.delete(); File f = new File("resources/matlab/"); File fWindow = new File("resources\\matlab\\aaa\\for_redistribution_files_only\\"); Runtime r = Runtime.getRuntime(); String[] command = { "cmd", "/c", "aaa.exe", fSpace.getText(), sRes.getText(), tRes.getText(), refFile, outputFile, Integer.toString(numFiles), fileType }; ProcessBuilder pb = new ProcessBuilder(); pb.directory(fWindow); pb.command(command); System.out.println(); try { Process p = pb.start(); try { p.waitFor(); System.out.print(p.exitValue()); closeOut(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } ''' 更多&回答... |
![]() |
![]() |