Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    48

    Post splash screen and menu screen in java me

    am currently developing an app but i have failed to connect the splash screen to the menu screen. When the app starts, it should bring the splash screen which has to wait for a minute and then the main menu appears with options.
    i have also failed to get the proper code for the menu which has options like exit,about ,help and start.
    here are codes: am using lcdui guide me on how i can also correct the codes

    import javax.microedition.lcdui.Display;
    import javax.microedition.midlet.MIDlet;

    public class Main extends MIDlet {

    private Menu mainmenu;

    private Display display;
    protected void startApp() {
    // TODO Auto-generated method stub
    if(display==null){
    display=Display.getDisplay(this);

    Splash splash=new Splash();
    display.setCurrent(splash);

    new Thread(){
    public void run(){
    try{
    sleep(1000);
    }catch (InterruptedException ie) {
    // TODO: handle exception
    }
    try{
    join();
    }catch (Exception e) {

    }
    }
    }.start();
    splash=null;
    }
    }
    protected void pauseApp() {
    // TODO Auto-generated method stub
    }
    protected void destroyApp(boolean unconditional)
    {
    }
    }



    menu.java

    package chr;

    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Font;
    import javax.microedition.lcdui.Graphics;

    public class Menu {

    private String[] options={"Start","About","Help","Exit"};
    int selectedRowPos=0;
    int bgcolor=(255<<16)+(255<<8)+255; //background color-white
    int fgcolor=(0<<16)+(0<<8)+0; //foreground color-black
    int hilightcolor=(84<<16)+(171<<8)+67; //menu highlight color
    Font bld=Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_SMALL);
    Font hed=Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_MEDIUM);

    //painting


    private void showMainMenu(Graphics g){
    int WIDTH=getWidth();
    int HEIGHT=getHeight();
    int gap=30;

    //set background and paint the header
    g.setColor(bgcolor);
    g.fillRect(0, 0, WIDTH, HEIGHT);
    g.setColor(fgcolor);
    g.setFont(hed);
    g.drawString("MainMenu", 5+(WIDTH/2),5, Graphics.TOP|Graphics.HCENTER);


    //drawing the menu options

    for(int x=0;x<3;x++){
    g.drawString(options[x], 60,65+x*gap, Graphics.TOP|Graphics.LEFT);

    //highlighting the selected option

    g.setColor(hilightcolor);
    g.fillRoundRect(2, 55, (selectedRowPos)*gap, WIDTH-2, gap-3, 3);
    g.setColor(fgcolor);
    g.drawString(options[selectedRowPos], 60, 65+(selectedRowPos)*gap,Graphics.TOP|Graphics.LEFT );

    //draw line and paint the footer
    g.drawLine(0, HEIGHT-35, WIDTH,HEIGHT-35);
    g.drawString("select", 2, HEIGHT-31,Graphics.LEFT|Graphics.TOP);
    g.drawString("fire", WIDTH/2, HEIGHT-31, Graphics.HCENTER|Graphics.TOP);
    }
    }
    private int getHeight() {
    // TODO Auto-generated method stub
    return 0;
    }
    private int getWidth() {
    // TODO Auto-generated method stub
    return 0;
    }
    //scrolling through the menu option is managed by the key pressed method of the canvas
    public void keyPressed(int keyCode){
    switch (getGameAction(keyCode)) {
    case Canvas.UP:
    break;
    case Canvas.DOWN:
    break;
    case Canvas.RIGHT:
    break;
    case Canvas.LEFT:
    break;
    case Canvas.FIRE:
    break;

    gotoOptions();

    break;
    }
    repaint();
    }
    private void repaint() {
    // TODO Auto-generated method stub

    }
    private void gotoOptions() {
    // TODO Auto-generated method stub
    switch(selectedRowPos){
    case 0:

    case 1:
    case 2:

    }

    }


    }

  2. #2
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    272

    Re: splash screen and menu screen in java me

    Hi

    Welcome to the Discussion Boards and Asha Developement.

    We have a huge number of Wiki articles on how to do various things in Jave Me.I would recommend you to look at the following articles among them

    http://developer.nokia.com/Community..._Splash_Screen.

    In the void splashScreenDone() method, you need to create a new instance of your menu and set the present display to it

    (i.e.. Display.getDisplay(this).setCurrent(new Menu()); )

    I am guessing that you have followed this article to make your main menu

    http://developer.nokia.com/Community...Menu_on_Canvas

    You need to make two changes to make your menu appear.

    1.) public class Menu { => public class Menu extends Canvas {

    2.) Add this code into this

    protected void paint(Graphics g)
    {
    showMainMenu(g);
    }

    Please note that this code is not optimized for Touch devices, and hence you wont find this to be working in Asha SDK 1.0 or Nokia SDK 2.0

    I would recommend a simple alternative instead.Use LCDUI Forms rather than Canvas

    Here is a sample code (put it under the splashScreenDone method) :
    Code:
            
            Form mainForm = new Form("My Awesome Game");
    
            StringItem si1 = new StringItem("New Game", null, StringItem.BUTTON);
            StringItem si2 = new StringItem("Options", null, StringItem.BUTTON);
            StringItem si3 = new StringItem("Help", null, StringItem.BUTTON);
            StringItem si4 = new StringItem("About", null, StringItem.BUTTON);
            StringItem si5 = new StringItem("Exit", null, StringItem.BUTTON);
    
            mainForm.append(si1);
            mainForm.append(si2);
            mainForm.append(si3);
            mainForm.append(si4);
            mainForm.append(si5);
    
            Display.getDisplay(this).setCurrent(mainForm);
    The above code will work in any JavaMe device.
    Last edited by arunkam; 2013-12-09 at 20:57.

  3. #3
    Registered User
    Join Date
    Jul 2013
    Posts
    48

    Re: splash screen and menu screen in java me

    thanks arunkam, could you please guide more how to make the menu screen class.

  4. #4
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    272

    Re: splash screen and menu screen in java me

    I just gave you the code to a menu screen.What difficulty are you facing in implementing this ?

Similar Threads

  1. J2ME start-up/splash screen blank screen issue
    By Magicake in forum Mobile Java General
    Replies: 3
    Last Post: 2012-01-04, 11:44
  2. Replies: 10
    Last Post: 2010-04-20, 07:51
  3. Displaying the next screen after splash screen
    By rachelwiz in forum Mobile Java General
    Replies: 8
    Last Post: 2009-08-24, 17:49
  4. Full screen splash screen
    By jitendrachhajed in forum Symbian
    Replies: 1
    Last Post: 2005-07-11, 08:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×