Vaadin Web应用开发教程(24):UI组件-ProgressIndicator组件
来源:互联网 发布:艾默生电气集团知乎 编辑:程序博客网 时间:2024/05/04 03:51
ProgressIndicator组件显示进程条,ProgressIndicator组件定时向服务器查询其当前值,如果值有变化,则更新进程条进度。Web应用本身无需实现任何查询服务器的操作,查询由ProgressIndicator组件自动完成。
ProgressIndicator组件的值域为0.0到1.0之间。缺省的查询(polling)间隔为1秒,可以使用setPollingInterval 修改。
// Create the indicatorfinal ProgressIndicator indicator = new ProgressIndicator(new Float(0.0));main.addComponent(indicator); // Set polling frequency to 0.5 seconds.indicator.setPollingInterval(500);
ProgressIndicator组件通常用来显示一些耗时操作(比如下载文件)的进度。 使用setValue 为ProgressIndicator组件设置当前值。
下面代码模拟一个费时操作提供ProgressIndicator组件显示进度。
// Create an indicator that makes you look busyfinal ProgressIndicator indicator = new ProgressIndicator(new Float(0.0));main.addComponent(indicator);// Set polling frequency to 0.5 seconds.indicator.setPollingInterval(500);// Add a button to start workingfinal Button button = new Button("Click to start");main.addComponent(button);// Another thread to do some workclass WorkThread extends Thread { public void run () { double current = 0.0; while (true) { // Do some "heavy work" try { sleep(50); // Sleep for 50 milliseconds } catch (InterruptedException e) {} // Show that you have made some progress: // grow the progress value until it reaches 1.0. current += 0.01; if (current>1.0) indicator.setValue(new Float(1.0)); else indicator.setValue(new Float(current)); // After all the "work" has been done for a while, // take a break. if (current > 1.2) { // Restore the state to initial. indicator.setValue(new Float(0.0)); button.setVisible(true); break; } } }}// Clicking the button creates and runs a work threadbutton.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final WorkThread thread = new WorkThread(); thread.start(); // The button hides until the work is done. button.setVisible(false); }});
- Vaadin Web应用开发教程(24):UI组件-ProgressIndicator组件
- Vaadin Web应用开发教程(24):UI组件-ProgressIndicator组件
- Vaadin Web应用开发教程(17):UI组件-Select 组件
- Vaadin Web应用开发教程(18):UI组件-Table 组件
- Vaadin Web应用开发教程(19):UI组件-Tree 组件
- Vaadin Web应用开发教程(20):UI组件-MenuBar组件
- Vaadin Web应用开发教程(21):UI组件-Embedded组件
- Vaadin Web应用开发教程(22):UI组件-Upload组件
- Vaadin Web应用开发教程(23):UI组件-Form组件
- Vaadin Web应用开发教程(25):UI组件-Slider组件
- Vaadin Web应用开发教程(26):UI组件-LoginForm组件
- Vaadin Web应用开发教程(27):UI组件-自定义组件
- Vaadin Web应用开发教程(21):UI组件-Embedded组件
- Vaadin Web应用开发教程(7):UI组件概述
- Vaadin Web应用开发教程(8):UI组件-Label
- Vaadin Web应用开发教程(9):UI组件-Link
- Vaadin Web应用开发教程(10):UI组件-TextField
- Vaadin Web应用开发教程(11):UI组件-TextArea
- 多进程 不同地址空间的数据共享问题
- Java第2讲
- 中国球员
- Java第二讲(由浅到深)
- Android ApiDemos示例解析(129):Views->Layout Animation->4. Randomize
- Vaadin Web应用开发教程(24):UI组件-ProgressIndicator组件
- 收费系统——纠结的钱!
- 平衡二叉树的使用
- C基础知识--指针与数组
- C++中的类和对象
- Windows Phone 开发学习笔记(十一) RSS阅读器之显示数据
- 进程管理
- 动力学模拟2
- 【养生】九转内丹术