문제가 있습니다. JTextArea (또는 JTextPane) 메서드에서 "setText (...)"(또는 "append), 작동하지 않습니다. 내 콘솔에 오류가 없습니다. 다음은 내가 사용하는 코드입니다.양식이 표시 될 때 setText (...) 작동하지 않습니다.
public class ConsoleFrame extends JDialog {
private static final long serialVersionUID = 1L;
private final JTextArea output = new JTextArea();
public ConsoleFrame() {
this.setTitle("Console");
this.setSize(500, 376);
this.setModal(true);
this.setModalityType(ModalityType.APPLICATION_MODAL);
this.setLocationRelativeTo(null);
final Container content = this.getContentPane();
output.setLineWrap(true);
output.setWrapStyleWord(true);
output.setText("Test 1");
content.add(new JScrollPane(output), BorderLayout.CENTER);
this.setVisible(true);
output.setText(System.lineSeparator() + "Test 2");
System.out.println(output.getText()); // Outputs "Test 1 Test 2";
}
}
당신의 도움에 감사드립니다!
이상하게도 코드를 실행하면 "테스트 1"이 콘솔에 표시되고 대화 상자를 닫으면 터미널에 "{새 라인} 테스트 2"가 인쇄됩니다. 모든 것이 "예상대로"작동합니다. 문제가 무엇인지 자세히 설명해 주시겠습니까? 모달 대화 상자에서'setVisible (true)'는 블로킹 호출이라는 것을 기억하십시오. –
내가 양식을 삭제하면 어쩌면? – Skyost
달성하려는 목표는 무엇입니까? 나는 너의 최종 목표가 무엇인지 이해하기가 어렵다. 설명하면 도움이 될 것입니다. –