Home Tutorials Echo3 Throwing Run time exception in Echo3
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Throwing Run time exception in Echo3

Advertisement
While creating any application the developers must be aware with the fact that there are lots of cases where the user may perform wrong inputs and wrong button pressing and such activities.

Throwing Run time exception in Echo3

     

While creating any application the developers must be aware with the fact that there are lots of cases where the user may perform wrong inputs and wrong button pressing and such activities. So to create a more user-friendly application its necessary that the developers handle the exception when they are thrown to avoid of making  application halted while application is in process. In Echo3 also, a user can throw runtime exceptions. Here is an example of application that throws a RuntimeException as described below. 

In the following application we have created a button which will throw a RuntimeException when user presses that button.Here is the full example source code in detail for application.

ExceptionServlet.java

package echo;

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

public class ExceptionServlet extends WebContainerServlet {

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

ExceptionApp.java

package echo;

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

  public Window init() {
  Window window = new Window();
  window.setTitle("Exception Example");
  ContentPane contentPane = new ContentPane();
  Button thr=new Button("Throw Run Time Exception");
  thr.setBorder(new Border(2,Color.BLUE,Border.STYLE_SOLID));
  contentPane.add(thr);
 thr.addActionListener(new ActionListener() {
 public void actionPerformed(ActionEvent e)
 {
 throw new RuntimeException("Application has thrown RuntimeException.");
 }
  });
  window.setContent(contentPane);
  return window;
  }  

Output:

Download Project Source Code

     

Advertisements

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

Related Tutorials

Ask Questions?    Discuss: Throwing Run time exception in Echo3  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com