- 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.
推薦閱讀
- HornetQ Messaging Developer’s Guide
- Mastering NetBeans
- Mastering AWS Lambda
- INSTANT MinGW Starter
- Scratch真好玩:教小孩學編程
- Nginx Essentials
- GameMaker Programming By Example
- 大數據分析與應用實戰:統計機器學習之數據導向編程
- Mastering Akka
- 快速入門與進階:Creo 4·0全實例精講
- RubyMotion iOS Develoment Essentials
- Java7程序設計入門經典
- Continuous Delivery and DevOps:A Quickstart Guide Second Edition
- 用Python動手學統計學
- Python深度學習(第2版)