JTextArea's append () method doesn't seem to work

前端 未结 1 1053
误落风尘
误落风尘 2021-01-19 15:35

We were assigned to create a simple compiler as a homework that will take set of instructions (containing variables, conditions, jumps, etc.) and evaluate them. That\'s alre

相关标签:
1条回答
  • 2021-01-19 16:37

    The code probably is called on the event handling loop, where you cannot have drawing. One would normally use

    final String line = bufferedReader.relineadLine();
    // final+local var so usable in Runnable.
    
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            input.append(line + "\n");
        }
    } 
    

    Unfortunately it takes some care where to place the invokeLatere (as looping). Better use @AndrewThompson's solution.

    0 讨论(0)
提交回复
热议问题