官术网_书友最值得收藏!

Time for action – adding components as class members

To add UI components as class members, edit your TimeItUI class by adding these variables to it:

private static final TestSet[] testSets = new TestSet[] {
  new LongVsInt(),
  new StringVsStringBuffer(),
  new ShortCircuitVsNoShortCircuit()
};

private VerticalLayout layout = new VerticalLayout();
private ComboBox combo = new ComboBox("Test");
private final TextField textField = new TextField("Number of
                                    iterations", "1000");
private CheckBox checkBox = new CheckBox("Keep previous results");
private Button button = new Button("Time it!");
private VerticalLayout resultsLayout = new VerticalLayout();

What just happened?

The first thing you see, testSets, is just an array of business objects, specifically, an array containing instances of TestSet (take a look at the TestSet interface in the book's source code). Think of TestSet as a single scenario from which we want to obtain timing results. For example, the LongVsInt class will run two tests: one to time a loop controlled by a long object type and another to time a loop controlled by an int object type. If you want to add some testing scenarios, all you must do is to implement the TestSet interface and add a new instance to the testSets array.

主站蜘蛛池模板: 漯河市| 晋州市| 冀州市| 隆安县| 铁岭市| 呼图壁县| 海兴县| 巍山| 阳西县| 普兰店市| 盐津县| 谷城县| 准格尔旗| 林甸县| 望城县| 万全县| 萨嘎县| 安吉县| 南郑县| 阿荣旗| 郸城县| 五大连池市| 赤峰市| 兴仁县| 铅山县| 尼木县| 翁牛特旗| 缙云县| 新密市| 九台市| 永州市| 天柱县| 徐闻县| 内江市| 邮箱| 耿马| 横山县| 尼木县| 岑溪市| 阆中市| 宁陵县|