Java에서 TextArea
을 지우는 데 문제가 있습니다. Button
을 클릭하면분명히 여기서 작동하지 않는 이유는 무엇입니까?
Button gen = new Button("generate");
gen.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
textArea.clear();
combination.init();
setPassword();
textArea.setText(password);
}
});
는 이벤트 핸들러는 TextArea
에 문자열 "암호"를 넣습니다. 그것은이를 수행하여 문자열을 가져옵니다 :
combination.init();
setPassword();
는 그런 다음 TextArea
에 문자열을 넣는다 :
textArea.setText(password);
Button
다시 클릭하면, 새로운 문자열을 생성하고 TextArea
에 투입 될 것입니다. 하지만 미리 지우지 않고 새 문자열을 마지막에 넣습니다.
int i = textArea.getParagraphs().size();
if(i != 0) {
textArea.clear();
}
이 그래서 내가 뭘 잘못?
TextArea
이 삭제되지 않는 이유는 무엇입니까?
문제는 'textArea.clear();'메소드와 관련이 없으며 어쨌든 쓸모가 없습니다. 'combination.init();'또는'setPassword();'메소드가 문제의 원인 일 수 있습니다. 이 방법들을 게시 할 수 있습니까? – pulkit
게시하지 않은 코드로 인해 문제가 발생했습니다. [MCVE]를 만듭니다. –
메소드'setPassword()'와'combination.init()'의 코드를 게시하십시오. –