private void addExampleUsingArrayList() {
		add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect created using an array list of options"));
		List<CarOption> options = new ArrayList<>();
		options.add(new CarOption("1", "Ferrari", "F-360"));
		options.add(new CarOption("2", "Mercedez Benz", "amg"));
		options.add(new CarOption("3", "Nissan", "Skyline"));
		options.add(new CarOption("5", "Toyota", "Prius"));

		final WCheckBoxSelect select = new WCheckBoxSelect(options);
		select.setToolTip("Cars");
		final WTextField text = new WTextField();
		text.setReadOnly(true);
		text.setText(NO_SELECTION);

		WButton update = new WButton("Select Cars");
		update.setAction(new Action() {
			@Override
			public void execute(final ActionEvent event) {
				String output = select.getSelected().isEmpty() ? NO_SELECTION : "The selected cars are: "
						+ select.getSelected();
				text.setText(output);
			}
		});
		select.setDefaultSubmitButton(update);

		add(select);
		add(update);
		add(text);
		add(new WAjaxControl(update, text));
	}
private void addExampleUsingArrayList ( ) { add ( new WHeading ( HeadingLevel . H3 , "WCheckBoxSelect created using an array list of options" ) ) ; List < CarOption > options = new ArrayList < > ( ) ; options . add ( new CarOption ( "1" , "Ferrari" , "F-360" ) ) ; options . add ( new CarOption ( "2" , "Mercedez Benz" , "amg" ) ) ; options . add ( new CarOption ( "3" , "Nissan" , "Skyline" ) ) ; options . add ( new CarOption ( "5" , "Toyota" , "Prius" ) ) ; final WCheckBoxSelect select = new WCheckBoxSelect ( options ) ; select . setToolTip ( "Cars" ) ; final WTextField text = new WTextField ( ) ; text . setReadOnly ( true ) ; text . setText ( NO_SELECTION ) ; WButton update = new WButton ( "Select Cars" ) ; update . setAction ( new Action ( ) { @ Override public void execute ( final ActionEvent event ) { String output = select . getSelected ( ) . isEmpty ( ) ? NO_SELECTION : "The selected cars are: " + select . getSelected ( ) ; text . setText ( output ) ; } } ) ; select . setDefaultSubmitButton ( update ) ; add ( select ) ; add ( update ) ; add ( text ) ; add ( new WAjaxControl ( update , text ) ) ; }
This example creates the WCheckBoxSelect from a List of CarOptions.