Home Tutorials Echo3 CheckBox component in Echo3


Share on Google+Share on Google+

CheckBox component in Echo3

Some of the very useful components that are common in any application development are CheckBox, ListBox, Button and RadioButton.

CheckBox component in Echo3


Some of the very useful components that are common in any application development are CheckBox, ListBox, Button and RadioButton. Here in this Check Box example we will describe you how to create CheckBox component in Echo3. We have used here the server-side API to create checkbox. CheckBox class can be found in the nextapp.echo.app package. 

There are four constructor of the class CheckBox as follows:

  • CheckBox() default constructor, will create a simple checkbox without any label 
  • CheckBox(ImageReference icon) will creates a check box with an icon
  • CheckBox(java.lang.String text) will creates a check box with label
  • CheckBox(java.lang.String text, ImageReference icon) it will creates a check box with label and an icon

To create CheckBox application in Echo3 we have created two java files as described below:

  • CheckBoxServlet.java
  • CheckBoxApp.java

CheckBoxServlet.java extends the WebContainerServlet and is responsible for creating a new application instance and returns a new instance of CheckBoxApp. We have created a grid here and have added two check box items into it. On the first check box object we have added the action listener and on another check box is simple without any action. Following is the full example code of our application as follows:


package check;

import nextapp.echo.app.ApplicationInstance;
import nextapp.echo.webcontainer.WebContainerServlet;

public class CheckBoxServlet extends WebContainerServlet{

  public ApplicationInstance newApplicationInstance(){
  return new CheckBoxApp();


package check;

import nextapp.echo.app.ApplicationInstance;
import nextapp.echo.app.ContentPane;
import nextapp.echo.app.Label;
import nextapp.echo.app.Window;
import nextapp.echo.app.*;

import nextapp.echo.app.event.*;

public class CheckBoxApp extends ApplicationInstance {
  private ContentPane contentPane;
  private CheckBox check1;
  private CheckBox check2;
  private Grid grid;
  private Window window;
  private WindowPane windowPane;

  public Window init() {
  window = new Window();
  contentPane = new ContentPane();
  grid = new Grid();
  windowPane = new WindowPane();
  windowPane.add(new Label("CheckBox Example"));
  check1 = new CheckBox("Check Box with action");
  check2 = new CheckBox("Check Box without action");
  grid.setBorder(new Border(2,Color.BLUE,Border.STYLE_SOLID));
 check1.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e)
  windowPane.setTitle("Check Box");
  return window;


Download Project Source Code



If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 23, 2008

Related Tutorials

Ask Questions?    Discuss: CheckBox component in Echo3  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image