【发布时间】:2022-01-04 06:04:19
【问题描述】:
我在 vaadin 7 中有一个窗口,我想显示所做的更改,因为我有更长的任务来处理它的想法。我偶然发现了this site,但我必须移动窗口才能看到更改。在我拥有的窗口中,我调用下一节课:
new PushyUI();
类调用:
public class PushyUI extends UI {
Chart chart = new Chart(ChartType.AREASPLINE);
DataSeries series = new DataSeries();
PushyUI() {
chart.setSizeFull();
setContent(chart);
// Prepare the data display
Configuration conf = chart.getConfiguration();
conf.setTitle("Hot New Data");
conf.setSeries(series);
// Start the data feed thread
new FeederThread().start();
}
class FeederThread extends Thread {
int count = 0;
@Override
public void run() {
try {
// Update the data for a while
while (count < 6) {
Thread.sleep(1000);
getUI().access(new Runnable() {
@Override
public void run() {
double y = Math.random();
series.add(new DataSeriesItem(count++, y),
true, count > 10);
}
});
}
// Inform that we have stopped running
getUI().access(new Runnable() {
@Override
public void run() {
setContent(new Label("Done!"));
}
});
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
如何在不移动窗口的情况下看到更改?谢谢
【问题讨论】:
-
我认为您需要展示如何启用服务器推送,您上面的代码没有显示注释或部署描述符。
-
查看此示例应用程序以获得最佳实践 Push 使用 Vaadin 7 github.com/TatuLund/bookstore-v7
-
我没有启用服务器推送。我有没有办法?
标签: multithreading java-8 vaadin7