JavaFX 2:表格:更新数据后更新显示
这就是我完成回答我的最后一个问题所需的全部内容。
如果你看我的最后一个问题,你会看到我的类,包含四个字段,对应于我的表的四列,
public static class ContactOptions {
private final StringProperty one;
private final StringProperty two;
private final StringProperty three;
private final StringProperty four;
ContactOptions(String col1, String col2, String col3, String col4) {
this.one = new StringProperty(col1);
this.two = new StringProperty(col2);
this.three = new StringProperty(col3);
this.four = new StringProperty(col4);
}
public String getOne() {
return one.get();
}
public String getTwo() {
return two.get();
}
public String getThree() {
return three.get();
}
public String getFour() {
return four.get();
}
}
如何在运行 ContactOptions.one.set
后更新 GUI?
当我向下滚动并向后滚动时,它会更新。我怎样才能让它在不滚动的情况下更新。
我还在 https://forums.oracle.com/forums/thread 询问了这个问题.jspa?threadID=2275725
This is all I need to finish answering my last question.
If you look at my last question, you will see my class, containing four fields, corresponding to the four columns of my table
public static class ContactOptions {
private final StringProperty one;
private final StringProperty two;
private final StringProperty three;
private final StringProperty four;
ContactOptions(String col1, String col2, String col3, String col4) {
this.one = new StringProperty(col1);
this.two = new StringProperty(col2);
this.three = new StringProperty(col3);
this.four = new StringProperty(col4);
}
public String getOne() {
return one.get();
}
public String getTwo() {
return two.get();
}
public String getThree() {
return three.get();
}
public String getFour() {
return four.get();
}
}
How do I get the GUI to update after I run ContactOptions.one.set
?
When I scroll down and back up, it updates. How can I get it to update without scrolling.
I also asked this at https://forums.oracle.com/forums/thread.jspa?threadID=2275725
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许您应该使用以下方法之一:
更新与此 TableCell 关联的 TableColumn。
更新与此 TableCell 关联的 TableRow。
更新与此 TableCell 关联的 TableView。
(来自 http://docs.oracle.com/javafx /2.0/api/javafx/scene/control/TableCell.html)
但我认为你已经处理了这个问题)
Maybe you should use one of the methods below:
Updates the TableColumn associated with this TableCell.
Updates the TableRow associated with this TableCell.
Updates the TableView associated with this TableCell.
(From http://docs.oracle.com/javafx/2.0/api/javafx/scene/control/TableCell.html)
But I think you had already handled this problem)
为了使更新无缝工作,您应该初始化每个属性并添加
xxxProperty
方法:根据我自己的经验,不要使用大写字母的属性名称,例如“myOne”或“myONE”,因为 < code>xxxProperty 方法将不会运行。
For updates to work seamlessly, you should initialize each property and add the
xxxProperty
method:From my own experience, do not use property names using upperCase letters, like "myOne" or "myONE", as the
xxxProperty
method won't run.您使用的是 JavaFX 2.0 的哪个版本?我问的原因是表格最近发生了变化,我想确保您使用的是最新版本。
Which build of JavaFX 2.0 are you using? The reason I ask is that tables changed recently and I want to make sure you are using the latest version.