Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Building a J2ME sliding menu with text and images(part-1) 
 

This example will show, how to create an image icon to perform the next action or next image from the list every time it's been clicked. So if you want to go from one icon to another icon by the nice sliding effect, you have to run the given example.

 

Building a J2ME sliding menu with text and images(part-1)

                         

This example will show, how to create an image icon to perform the next action or next image from the list every time it's been clicked. So if you want to go from one icon to another icon by the nice sliding effect, you have to run the given example. For developing this application we have inherit canvass class and implement Runnable Interface. The Runnable interface is called from java.lang package and this interface has only one methods which is called: run() method. The function to run the application is as follows which is used in this application:

public void run(){
    try{
      while(true){
        repaint();
        synchronized(this){
          wait(100L);
        }
      }
    }catch(Exception e){
      e.printStackTrace();
    }
  }

And the following image is created in this application is as follows:

image[0] = Image.createImage("/bollywood-height.png");
image[1] = Image.createImage("/212229_1193669628.png");
image[2] = Image.createImage("/95936_50.png");
image[3] = Image.createImage("/shreya.png");
image[4] = Image.createImage("/Aishw.png");
image[5] = Image.createImage("/karishma.png");
image[6] = Image.createImage("/tmb_jiahkhannishabd.png");
image[7] = Image.createImage("/amisha.png");
image[8] = Image.createImage("/shilpashetty.png");
image[9] = Image.createImage("/priti.png");

The Sample of Application is as follows:

 

Source Code of SlideImage.java

 
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class SlideImage extends MIDlet{
  private Display display;

  public void startApp(){
    display = Display.getDisplay(this);
    display.setCurrent(new IconsCanvas())
  }

  public void pauseApp(){}

  public void destroyApp(boolean unconditional){
    notifyDestroyed();
  }
}

class IconsCanvas extends Canvas implements Runnable{
  SlideMenu menu = null;

  public IconsCanvas(){
    Image[] image = new Image[10];     
    try{
      image[0= Image.createImage("/bollywood-height.png");
      image[1= Image.createImage("/212229_1193669628.png");
      image[2= Image.createImage("/95936_50.png");
      image[3= Image.createImage("/shreya.png");
      image[4= Image.createImage("/Aishw.png");
      image[5= Image.createImage("/karishma.png");
      image[6= Image.createImage("/tmb_jiahkhannishabd.png");
      image[7= Image.createImage("/amisha.png");
      image[8= Image.createImage("/shilpashetty.png");
      image[9= Image.createImage("/priti.png");
      
      menu = new SlideMenu(new String[]{"1""2""3""4"
     
"5""6""7""8""9""10"},  
        image,  getWidth
(),  getHeight());
      new Thread(this).start();
    }catch(Exception e){
      e.printStackTrace();
    }
  }

  protected void paint(Graphics g){
    menu.paint(g);
  }

  public void keyPressed(int key){
    int gameKey = getGameAction(key);
    if(gameKey == Canvas.RIGHT){
      menu.slideItem(1);
    }else if(gameKey == Canvas.LEFT){
      menu.slideItem(1);
    }
  }

  public void run(){
    try{
      while(true){
        repaint();
        synchronized(this){
          wait(100L);
        }
      }
    }catch(Exception e){
      e.printStackTrace();
    }
  }
}

Download Source Code

                         

» View all related tutorials
Related Tags: c io vi lock this block set frame example ram exam locks e il manual blocks man in as m

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 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

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.