More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Loading delay component in Echo3

                         

In the previous section of Echo3 tutorial you must have studied about how you can create a server-side application in the Echo3 web framework using the server side API. Now in this example we have created an application which will describe how to create delay component loading. To create a delay component loading we have created two java classes DelayServlet.java and DelayApp.java.

DelayServlet.java extends WebContainerServlet and creates a new application instance by returning the DelayApp object. DelayApp class extends the abstract class ApplicationInstance and it must overrides the init() method. The method init() must return an object of type Echo Window. Here we will be creating the object of ContentPane for adding contents to the application window. 

 

 

 

 

Button load =new Button("LOAD WINDOW");
    contentPane.add(load);

Above lines of code creates a Button and add it to the ContentPane. Now on the button click we have called the action listener which will describe that what action is to be performed when button is clicked. Here is the code for action to be performed as given below.

 load.addActionListener(new ActionListener() {
     
public void actionPerformed(ActionEvent e) {
      try
                {
                    Thread.sleep(5000L);
          windowPane.setTitle("Welcome! to ROSEINDIA");
          windowPane.setTitleInsets(new Insets(105));
          windowPane.setInsets(new Insets(10));
          windowPane.setWidth(new Extent(500));
          windowPane.setHeight(new Extent(280));
          windowPane.setStyleName("Glass Blue");
          windowPane.setModal(true);
          windowPane.add(new Label("Window loaded after 5 seconds"));
          contentPane.add(windowPane);
                }
                catch(InterruptedException ex) { }
            }
        });

Here is the full code of application.

DelayServlet.java

package delay;

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

public class DelayServlet extends WebContainerServlet {

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

DelayApp.java

package delay;

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 DelayApp extends ApplicationInstance {

 private WindowPane windowPane;
 private ContentPane contentPane;

    public Window init() {
        Window window = new Window();
    window.setTitle("Delay example");
    contentPane = new ContentPane();
         windowPane = new WindowPane();
    Button load =new Button("LOAD WINDOW");
    contentPane.add(load);
    load.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      try
                {
                    Thread.sleep(5000L);
          windowPane.setTitle("Welcome! to ROSEINDIA");
          windowPane.setTitleInsets(new Insets(105));
          windowPane.setInsets(new Insets(10));
          windowPane.setWidth(new Extent(500));
          windowPane.setHeight(new Extent(280));
          windowPane.setStyleName("Glass Blue");
          windowPane.setModal(true);
          windowPane.add(new Label("Window loaded after 5 seconds"));
          contentPane.add(windowPane);
                }
                catch(InterruptedException ex) { }
            }
        });
    window.setContent(contentPane);
        return window;
    }  

Output :

When user click on the button "LOAD WINDOW" it starts loading window and it takes 5 seconds in loading window since we have programmed it to do so.

Download Project Source Code

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Join and Excel yourself with our Online instructor led training sessions
Training Courses
Tell A Friend
Your Friend Name

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.