Home Tutorials Echo3 CheckBox component in Echo3



CheckBox component in Echo3
Posted on: November 23, 2008 at 12:00 AM
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:

CheckBoxServlet.java

package check;

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

public class CheckBoxServlet extends WebContainerServlet{

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

CheckBoxApp.java

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));
  grid.add(check1);
  grid.add(check2);
 check1.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e)
  {
  windowPane.setTitle("Check Box");
  contentPane.add(windowPane);
  }
 });
 contentPane.add(grid);
 window.setContent(contentPane);
  return window;
 }  

Output:

Download Project Source Code

     

Related Tags for CheckBox component in Echo3:
capicomideclasslistserverdevelopmentapplicationlistboxbuttoncheckboxiocomponentssedradiobuttoncomponentthisidserver-sidepackageappradcreatecheckechoexampleboxradiotoexamexteildescanliuseuldevinasmntnextsidsidecapackadclestapcommonagepimehowppackcatdescribexaxampssoatanypackishallmpldevelopeaandarrvxtttscrssritbothavstatiaphatkbicaicapleplndonomo


More Tutorials from this section

Ask Questions?    Discuss: CheckBox component in Echo3  

Post your Comment


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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.