RichTextArea 允許輸入帶格式的文本。 RichTextArea 內(nèi)容以 HTML 格式顯示。它繼承自TextArea,本身沒(méi)有提供什麼附加功能,你可以通過(guò)擴(kuò)展 VRichTextArea, VRichTextToolbar 的方法來(lái)為 RichTextArea 添加客戶端功能。
// Create a rich text area
final RichTextArea rtarea = new RichTextArea();
rtarea.setCaption("My Rich Text Area");
// Set initial content as HTML
rtarea.setValue("<h1>Hello</h1>\n" +
"<p>This rich text area contains some text.</p>");
http://wiki.jikexueyuan.com/project/vaadin-web-development-tutorial/images/32.png" alt="" />
可以看到 RichTextArea 控制項(xiàng)本身帶有一個(gè)工具條,其中的選擇框使用英語(yǔ)而不支持本地化,但你可以通過(guò)派生或重新定義 VRichTextToolbar 來(lái)實(shí)現(xiàn)本地化。 而工具條上按鈕可以通過(guò) CSS 重新定義來(lái)實(shí)現(xiàn)本地化。 例如:
.v-richtextarea-richtextexample .gwt-ToggleButton
.gwt-Image {
background-image: url(img/richtextarea-toolbar-fi.png)
!important;
}
下圖為英語(yǔ)和本地化的 RichTextArea 工具條上按鈕。
http://wiki.jikexueyuan.com/project/vaadin-web-development-tutorial/images/33.png" alt="" />