Home Tutorials Echo3 Visibility of Components in Echo3

Related Tutorials


Share on Google+Share on Google+

Visibility of Components in Echo3

In the previous section of Echo3 tutorial you have developed the basic server side application examples.

Visibility of Components in Echo3


In the previous section of Echo3 tutorial you have developed the basic server side application examples. Now in this part of Echo3 tutorials we will describe you that how you can use other basic components property to make your application useful. We will be setting the "visible" property of the text field with the command buttons. We have used the property setVisible(boolean) to do this functionality.

Here we have created two of the java classes:

  1. VisibilityServlet.java
  2. VisibilityApp.java 

VisibilityServlet extends the WebContainerServlet, it processes the HTTP connection and returns VisibilityApp application instance.




package visible;

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

public class VisibilityServlet extends WebContainerServlet {

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

In VisibilityApp we have used TextField class that is the component, whose property we are going  to change. We have added two buttons "Visible=False" and "Visible=True" into the Grid class object. On these button when clicked the action listener would be called and it will call the appropriate action event to be performed on the components.


package visible;

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.ActionListener;
import nextapp.echo.app.event.ActionEvent;

public class VisibilityApp extends ApplicationInstance {
  private TextField text;

public Window init() {
  Window window = new Window();
  window.setTitle("Components Visibility");
  ContentPane contentPane = new ContentPane();
  text=new TextField();
  text.setText("Welcome to RoseIndia!");
  Grid grid=new Grid();
  Button buttonFalse = new Button("Visible=False");
  buttonFalse.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e)
  Button buttonTrue = new Button("Visible=True");
  buttonTrue.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e)
  return window;


To run this example download project, start your Tomcat Web server and type the following URL into your browser's address bar:

While you will click on the button "Visible=False" it will hide the text field by setting its setVisible() property value to false. 

Download Source Project



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 22, 2008

Related Tutorials

Discuss: Visibility of Components in Echo3  

Post your Comment

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