Generic AboutForm class for J2ME / JavaME application

 

I've seen a lot of J2ME / JavaME application authors create their own 'About' or 'Help' form to provide information regarding their MIDlet application. Most of this 'About' page are re-invented each time the author releases a new application generating inconsistencies between application.

Moreover there are also another breed of authors that take a far more lazy approach by abusing the 'Alert' class to include 'About' information. On most phones, This will severely limits the amount of text displayed on the phone screen regarding the application information.

The Solution : A generic AboutForm
In light of this situation, I decided to create a generic AboutForm (derives from the familiar 'Form' class) which provides a consistent look of a proper "About" page on your application. All you need to do is to initialize the class and use it just like ordinary "Form" class.

aboutformscreenshot.png

AboutForm class features

  • Consistent look on your applications
  • Reusability - You don't need to rewrite the about form class
  • Pre-arrange layout, the application/company logo, name, copyright notice and hyperlink are nicely arranged on the form
  • Easy to use and inuitive
  • You can stop wasting your time creating an About form for each of your applications
  • Clean and straight forward - just initiate the class and let it do all the work for you

Here's a snippets of example usage :

JAVA:
  1. AboutForm aboutForm;
  2. ..
  3. ..
  4. //initialize about form, place logo.png in res folder inside the MIDlet apps folder.
  5. aboutForm = new AboutForm("About","AboutFormDemo 1.0","/logo.png");
  6.  
  7. //set copyright notice
  8. aboutForm.setCopyright("mypapit","2007");
  9.        
  10. //set hyperlink
  11. aboutForm.setHyperlink("http://mobilepit.com",this);
  12.        
  13. //set commandlistener
  14. aboutForm.setCommandListener(this);
  15.        
  16. //add additional notice
  17. aboutForm.append("This is a demonstration of generic AboutForm class.");
  18.  
  19.  ...   
  20.  ...
  21.  
  22. public void commandAction(Command c, Displayable d) {
  23.        
  24.        if (c == exitCommand) {
  25.             destroyApp(false);
  26.             notifyDestroyed();
  27.         } else if (c == aboutCommand) {
  28.        
  29.         //display the about form
  30.         display.setCurrent(aboutForm);
  31.            
  32.     } else if (c == aboutForm.DISMISS_COMMAND) {
  33. //this will handle "Back"
  34. //notice that aboutForm uses DISMISS_COMMAND as its Command object similar to Alert class in MIDP 2.0
  35.             display.setCurrent(mainForm);
  36.         }
  37. }

Download AboutForm class (MIDP 2.0)
Here are the link to the downloads :

Tags: , , , , , , , , , ,

Bookmark this post : These icons link to social bookmarking sites where readers can share and discover new web pages.
  • co.mments
  • del.icio.us
  • digg
  • YahooMyWeb
  • DZone
  • StumbleUpon
  • Technorati

 

Recommended Reading

Leave a Comment

Subscribe by Email


Powered by FeedBlitz

 


Your Ad Here