鍍金池/ 教程/ Java/ UI 組件-Slider 組件
UI 組件-自定義組件
UI 布局-Panel
UI 組件-Slider 組件
UI 組件-Button
UI 組件-PasswordField
UI 布局-TabSheet 布局
Vaadin Web 應(yīng)用的基本組成部分
UI 組件-Label
UI 組件-Link
UI 布局-GridLayout 布局
安裝開發(fā)環(huán)境
UI 組件-Tree 組件
UI組件-Select 組件
UI 布局-概述
UI 組件-RichTextArea
UI 組件-Table 組件
使用 Item 介面管理一組 Property
使用資源
UI 組件-TextArea
SQLContainer-編輯
SQLContainer-過濾及排序
UI 組件-TextField
UI 布局-HorizontalSplitPanel 和 VerticalSplitPanel 布局
SQLContainer-引用其它 SQLContainer
UI組件-ProgressIndicator組件
開始編寫 Web 應(yīng)用
UI組件-Form組件
UI 布局-Accordion 布局
SQLContainer-使用 FreeformQuery
SQLContainer 概述
使用主題-創(chuàng)建和應(yīng)用新主題
概述
UI 布局-AbsoluteLayout 布局
UI 組件-Upload 組件
使用主題-概述
UI 布局-FormLayout 布局
MenuBar 組件
UI 布局-VerticalLayout 和 HorizontalLayout 布局
UI 組件-Embedded 組件
UI 組件概述
使用 Container 介面管理一組 Item
UI 組件-LoginForm 組件
數(shù)據(jù)綁定-Property 接口
Vaadin 應(yīng)用程序框架介紹
開始使用 SQLContainer
UI 組件-Checkbox
可視化界面編輯插件
數(shù)據(jù)綁定-概述

UI 組件-Slider 組件

Slider 組件可以顯示為垂直或是水平滑動條,可以使用鼠標(biāo)拖動來設(shè)置其值。 其基本使用如下:

// Create a vertical slider
final Slider vertslider = new Slider(1, 100);
vertslider.setOrientation(Slider.ORIENTATION_HORIZONTAL);

// Shows the value of the vertical slider
final Label vertvalue = new Label();
vertvalue.setSizeUndefined();

// Handle changes in slider value.
vertslider.addListener(new Property.ValueChangeListener() {

    public void valueChange(
            com.vaadin.data.Property.ValueChangeEvent event) {
         double value = (Double) vertslider.getValue();

        vertvalue.setValue(String.valueOf(value));

    }
});

// The slider has to be immediate to send the changes
// immediately after the user drags the handle.
vertslider.setImmediate(true);

http://wiki.jikexueyuan.com/project/vaadin-web-development-tutorial/images/67.png" alt="" />

Slider 組件也屬于 Field 組件,因此可以通過 ValueChangeListener 來監(jiān)聽 Slider 組件值的變化。同樣可以使用 setValue 來修改 Slider 組件的值,此時要注意 Catch 可能的ValueOutOfBoundsException。

// Set the initial value. This has to be set after the
// listener is added if we want the listener to handle
// also this value change.
try {
 vertslider.setValue(50.0);
} catch (ValueOutOfBoundsException e) {
}

Tags: Java EE, Vaadin, Web