对于 vaadin 7,更改在 window 中不可见

the changes are not visible in window for vaadin 7

我在 vaadin 7 中有一个 window,我想展示所做的更改,因为我有更长的任务来思考。我偶然发现 this site 但我必须移动 window 才能看到变化。在我拥有的 window 中,我用 :

调用下一个 class
new PushyUI();

class 叫:

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();
                }
            }
        }
   }

如何在不移动 window 的情况下看到更改?谢谢

我找到了解决方案 here。我设法修改了它对我有用。

            layout = new HorizontalLayout();
            layout.setSpacing(true);
            layout.setSizeFull();
     
            // Add a normal progress bar
            sample = new ProgressBar();
            layout.addComponent(sample);
            layout.setComponentAlignment(sample, Alignment.MIDDLE_CENTER);
     
            startButton = new Button("Start", new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    sample.setValue(0f);
                    sample.setVisible(true);
                    startButton.setEnabled(false);
                    UI.getCurrent().setPollInterval(500);
     
                    launchProgressUpdater(UI.getCurrent(), 10);
                }
            });
            startButton.setStyleName(ValoTheme.BUTTON_SMALL);
            layout.addComponent(startButton);
            layout.setComponentAlignment(startButton, Alignment.MIDDLE_CENTER);
     
    ...
     
        private void launchProgressUpdater(UI ui, int maxProgress) {
            new Thread(() -> {
                for (int progress = 1; progress <= maxProgress; progress++) {
                    try {
                        Thread.sleep(1000);
                    } catch (final InterruptedException e) {
                        throw new RuntimeException("Unexpected interruption", e);
                    }
                    updateProgressBar(ui, progress, maxProgress);
                }
            }).start();
        }
     
        private void updateProgressBar(UI ui, int progress, int maxProgress) {
            ui.access(() -> {
                final float newValue;
                if (progress == maxProgress) {
                    ui.setPollInterval(-1);
                    startButton.setEnabled(true);
                    newValue = 0f;
                    sample.setVisible(!sample.isIndeterminate());
                } else {
                    newValue = (float) progress / maxProgress;
                }
                sample.setValue(newValue);
                Notification.show("Value changed:", Float.toString(newValue), Notification.Type.TRAY_NOTIFICATION);
            });
        }