Home Tutorials Echo3 Visibility of Components in Echo3



Visibility of Components in Echo3
Posted on: November 22, 2008 at 12:00 AM
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.

 

 

VisibilityServlet.java

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.

VisibilityApp.java 

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();
  grid.add(text);
  Button buttonFalse = new Button("Visible=False");
  buttonFalse.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e)
  {
     text.setVisible(false);
  }  
  });
  grid.add(buttonFalse);
  Button buttonTrue = new Button("Visible=True");
  buttonTrue.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e)
  {
     text.setVisible(true);
  }  
  });
  grid.add(buttonTrue);
  contentPane.add(grid);
  window.setContent(contentPane);
  return window;
  }  

Output:

To run this example download project, start your Tomcat Web server and type the following URL into your browser's address bar:
http://localhost:8080/echo3/app/visible

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

     

Related Tags for Visibility of Components in Echo3:
ccomideservertextfunctionapplicationtutorialsbuttonfuniocomponentsmakepropertysedbooleancommandexamplesvitutorialcomponentfieldoleriathisidsetfunctionalooappbasicechobuttonstexbooieexampleuncwithtoexamldboolexteilvisibleitdessectionlscommacanliuseulpemandevartinnopartasmntparsidsidecaleanesfunchowproppcatdodescribetorxaxampsatkishallmplproperpredevelopeafunctionalityandarrtropervsettingxttttutorscrssrithavatiaphaticaicapleplpropprndonomolo


More Tutorials from this section

Ask Questions?    Discuss: Visibility of Components 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.