WebCheckBox

General

A WebCheckBox is a component that can be in either a 'selected' or an 'unselected' state. Clicking on a check box changes its state from 'selected' to 'unselected' or vice versa. A text (label) may be specified which is displayed near the WebCheckBox.

Example

Below fou find an example of how to use a WebCheckBox. You can try this example online: http://www.innoopract.com/w4content/

Properties of the WebCheckBox Component can be easily set in the Property-Editor of the W4T Eclipse Perspective. This example shows how to select and unselect a WebCheckBox or to change its label programmatically. The code is located in the in the event handler section and executed when buttons or checkboxes are clicked.

The example WebCheckBox is named wcbExample.

  private void doWbtValueControlWebActionPerformed( WebEvent e ) throws Exception {
    boolean currentlyChecked = wcbExample.isSelected();
    if( currentlyChecked ) {
      makeUnselected();
    } else {
      makeSelected();
    }
  }
  
  private void doWcbExampleWebItemStateChanged( WebEvent e ) throws Exception {
    boolean toCheck = !wcbExample.isSelected();
    if( toCheck ) {
      makeUnselected();
    } else {
      makeSelected();
    }
  }
  
  private void doWcbVisibleControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebCheckBox wcb = ( WebCheckBox )e.getSource();
    boolean visibility = wcb.isSelected();
    wcbExample.setVisible( visibility );
  }
  
  private void doWbtLabelControlWebActionPerformed( WebEvent e ) throws Exception {
    String value = wtxLabelControl.getValue();
    wcbExample.setLabel( value );
  }
  
  private void makeUnselected() throws Exception {
    wcbExample.setSelected( false );
    wlbValueDisplayControl.setValue( "The WebCheckBox is currently not selected." );
    wbtValueControl.setLabel( "Select it!" );
  }
  
  private void makeSelected() throws Exception {
    wcbExample.setSelected( true );
    wlbValueDisplayControl.setValue( "The WebCheckBox is currently selected." );
    wbtValueControl.setLabel( "Unselect it!" );
  }
  

API documentation

The API documentation for WebCheckBox can be found here.