그래서 Sudoku 해결사를 완성했지만 개선하고 싶습니다. 이렇게하려면 어떻게 든 documentListener
에서 내 betterJTextField
에 도달해야합니다. documentListener
을 사용하여 betterJTextFields
에서 실시간으로 읽을 수 있습니다. 문제는 insertUpdate(DocumentEvent e)
입니다.DocumentListener에서 JTextField에 도달
은 내가 DocumentEvent
가에서 일어난 betterJTextfield
에 도달해야합니다. 예를 들어, 잘못된 입력되면, betterJTextfield
등 적색으로 바뀌고
내가 가진 내 모든 당신이 알 필요가 있다면 매트릭스에서 betterJTextfield
. 모든 필드는 스도쿠에서 하나의 숫자를 처리합니다.
@Override
public void insertUpdate(DocumentEvent e) {
//Removed code which checks if the input in the betterJTextField is fine.
}
(JFormattedTextfield
이 확장 JTextField
)
public class betterJTextField extends JFormattedTextField {
private int row;
private int column;
public betterJTextField(Format format, int row, int column) {
super(format);
this.row = row;
this.column = column;
// TODO Auto-generated constructor stub
}
public int getRow() {
return row;
}
public int getColumn() {
return column;
}
, 고맙습니다. 왜 그렇게 생각하지 않았어 :) – Jakkra