- Vaadin 7 UI Design By Example:Beginner’s Guide
- Alejandro Duarte
- 165字
- 2021-08-13 16:17:40
Time for action – showing the results
The default behavior of the application is to show only the results of the last execution. We need to remove all the results that have been previously added to the resultsLayout
component if the user has not checked Keep previous results. To do that, implement your showResults
method:
private void showResults(Collection<String> results) { if(!checkBox.getValue()) { resultsLayout.removeAllComponents(); } else if(resultsLayout.getComponentCount() > 0) { resultsLayout.addComponent(new Label("--")); } for(String result : results) { resultsLayout.addComponent(new Label(result)); } }
What just happened?
If the checkbox is not checked, we can remove all the components in resultsLayout
(not in layout
, we don't want baffled users here):
resultsLayout.removeAllComponents();
If we don't have to remove previous results, we add a separator and iterate over the results to add each one using a label.
Tip
You can remove single components from layouts using the removeComponent
method:
layout.removeComponent(someComponent);
Congratulations! We have finished a useful application. Try implementing your own test sets and learn more about Java performance.
推薦閱讀
- JBoss Weld CDI for Java Platform
- 案例式C語(yǔ)言程序設(shè)計(jì)
- 大學(xué)計(jì)算機(jī)應(yīng)用基礎(chǔ)實(shí)踐教程
- 前端跨界開(kāi)發(fā)指南:JavaScript工具庫(kù)原理解析與實(shí)戰(zhàn)
- arc42 by Example
- C語(yǔ)言程序設(shè)計(jì)
- 編譯系統(tǒng)透視:圖解編譯原理
- Java設(shè)計(jì)模式及實(shí)踐
- MySQL入門很輕松(微課超值版)
- QGIS Python Programming Cookbook(Second Edition)
- 超好玩的Scratch 3.5少兒編程
- Python趣味創(chuàng)意編程
- PHP程序設(shè)計(jì)高級(jí)教程
- Java Web開(kāi)發(fā)任務(wù)教程
- Web前端開(kāi)發(fā)全程實(shí)戰(zhàn):HTML5+CSS3+JavaScript+jQuery+Bootstrap