我如何跨两个类使用JTextField。例如,从一个类中获取一个整数值,并将其显示在另一类中的textField中。从jFrame到JFrame
最佳答案
然后嵌套,这样就得到了一个类,该类获取实际显示该整数值的整数值,例如:
//Note: this is only a rough representation of the concept
// what I am trying to get across, it wouldn't really
// work like this
class Displayer{
ValueGetter valueGetter;
JTextField textField;
public Displayer(){
valueGetter = new ValueGetter();
}
public void display(){
int value = valueGetter.workOutValue();
textField.setText(value);
}
}