실례합니다. 어리석은 것처럼 보일지 모르겠지만 궁금합니다. 자바에서 GUI를 가질 프로그램을 만들고 있는데, 속성에 대한 전체적인 생각이 궁금합니다. 클래스에 데이터를 추가 할 수있는 이유는 무엇입니까? 예를 들어 :왜 JavaFX 속성을 사용합니까?
class myButton extends Button {
private boolean booleanProperty = false;
myButton(args...) {
// Do something with the property
}
public void setProperty(boolean value) {
this.booleanProperty = value;
}
public boolean getProperty() {
return this.booleanProperty;
}
}
버튼의 사용자 정의 구현에 대한 추가 정보를 저장하기 위해 잘 작동하는 것 같다. 하지만 무엇에 대해 :
class myButton extends Button {
private SimpleBooleanProperty booleanProperty = new SimpleBooleanProperty(false);
myButton(args...) {
// Do something with the property
}
public void setProperty(boolean value) {
this.booleanProperty.set(value);
}
public boolean getProperty() {
return this.booleanProperty.get();
}
}
유일한 차이는, 나는 (내가 틀렸다면 정정 해줘)보고하고는 속성 값에 수신기를 부착 할 수 있는지,하지만 더있을 경우 같은 느낌 그것보다. 아이디어?
실제로 청취자를 연결하는 것이 유일한 차이점이지만 생각만큼 사소한 것은 아닙니다. –
또한 객체 모델에서 UI에 구현을 그릴 때 반은 시간을 절약 할 수 있으므로 시간을 절약 할 수 있습니다. – Elltz