一 二 三级界面的连接 问题 (1)

目前已经实现主界面与二级界面的相互连接多谢亚日的帮助  现在想让二级界面与三级界面之间相互连接  

本人刚学不久 其中中的很多原理还不是太懂  希望大家帮忙啊


主界面  
package ui;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class MainFace extends MIDlet implements CommandListener {
    private Display dis;

    // 按钮
    private Command cmdOption;

    private Command cmdOkcheci;

    private Command cmdOkjiudian;

    private Command cmdOkluxian;

    private Command cmdBack;

    private Command cmdExit;

    

    int index = 0;
    

    // 创建界面
    public MainFaceCanvas fc = new MainFaceCanvas();

//     private HelpCanvas hc = new HelpCanvas();

    private RouteCanvas rc;
    private HoteCanvas hc;
    private TrainNumberCanvas tnc;
    private HelpCanvas hec;
    
    public MainFace() {
        dis = Display.getDisplay(this);
        rc = new RouteCanvas(this);
        hc = new HoteCanvas(this);
        tnc = new TrainNumberCanvas(this);
        hec = new HelpCanvas(this);
        cmdOption = new Command("操作", Command.SCREEN, 1);
        cmdOkcheci = new Command("确定", Command.SCREEN, 2);
        cmdOkjiudian = new Command("确定", Command.SCREEN, 3);
        cmdOkluxian = new Command("确定", Command.SCREEN, 4);
        cmdBack = new Command("返回", Command.SCREEN, 1);
        cmdExit = new Command("退出", Command.EXIT, 1);
        

    }

    protected void startApp() throws MIDletStateChangeException {
        dis.setCurrent(fc);
    }

    protected void pauseApp() {
        this.notifyDestroyed();
    }

    protected void destroyApp(boolean arg0) throws MIDletStateChangeException {

    }

    public void commandAction(Command c, Displayable d) {
        if (c == List.SELECT_COMMAND) {

        } else if (c == cmdOption) {

        } else if (c == cmdBack) {
            dis.setCurrent(fc);

        } else if (c == cmdExit) {

            notifyDestroyed();
        } else if (c == cmdOkcheci) {

        } else if (c == cmdOkjiudian) {

        } else if (c == cmdOkluxian) {
            try {
                destroyApp(true);
            } catch (Exception e) {
            }
        }
    }

    class MainFaceCanvas extends Canvas {
        int x = this.getWidth();
        int y = this.getHeight();
        private Image img1 ;
        private Image img2 ;
        private Image img3 ;
        private Image img4;
        private Image img11 ;
        private Image img22 ;
        private Image img33 ;
        private Image img44;
        public MainFaceCanvas(){
try{
img1= Image.createImage("/01.png");
img2= Image.createImage("/02.png");
img3= Image.createImage("/03.png");
img4= Image.createImage("/04.png");
img11= Image.createImage("/011.png");
img22= Image.createImage("/022.png");
img33= Image.createImage("/033.png");
img44= Image.createImage("/044.png");
}catch(Exception ex){
ex.printStackTrace();
}
}

        public void paint(Graphics g) {
            g.setColor(69, 132, 217);
            g.fillRect(0, 0, this.getWidth(), this.getHeight());
            g.setColor(225, 225, 225);
            g.setStrokeStyle(Graphics.SOLID);
            Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD,
                    Font.SIZE_LARGE);
            g.setFont(font);
            g.drawString("旅友无忧", 90, 5, Graphics.LEFT | Graphics.TOP);
            g.setColor(225, 225, 225);
            
            g.drawImage(img11,40, 60,Graphics.TOP|Graphics.LEFT);
            g.drawImage(img22,130, 60,Graphics.TOP|Graphics.LEFT);
            g.drawImage(img33,40, 150,Graphics.TOP|Graphics.LEFT);
            g.drawImage(img44,130, 150,Graphics.TOP|Graphics.LEFT);
            
          if (index == 1){//这个界面没给出
            g.drawImage(img1,40, 60,Graphics.TOP|Graphics.LEFT);
            g.drawImage(img22,130, 60,Graphics.TOP|Graphics.LEFT);
               g.drawImage(img33,40, 150,Graphics.TOP|Graphics.LEFT);
               g.drawImage(img44,130, 150,Graphics.TOP|Graphics.LEFT);
           }
           if (index == 2){//这个界面给出
            g.drawImage(img11,40, 60,Graphics.TOP|Graphics.LEFT);
            g.drawImage(img2,130, 60,Graphics.TOP|Graphics.LEFT);
               g.drawImage(img33,40, 150,Graphics.TOP|Graphics.LEFT);
               g.drawImage(img44,130, 150,Graphics.TOP|Graphics.LEFT);
           }
           if (index == 3){//这个也没给出
            g.drawImage(img11,40, 60,Graphics.TOP|Graphics.LEFT);
            g.drawImage(img22,130, 60,Graphics.TOP|Graphics.LEFT);
               g.drawImage(img3,40, 150,Graphics.TOP|Graphics.LEFT);
               g.drawImage(img44,130, 150,Graphics.TOP|Graphics.LEFT);
           }
           if (index == 4){//这个也没给出
            g.drawImage(img11,40, 60,Graphics.TOP|Graphics.LEFT);
            g.drawImage(img22,130, 60,Graphics.TOP|Graphics.LEFT);
               g.drawImage(img33,40, 150,Graphics.TOP|Graphics.LEFT);
               g.drawImage(img4,130, 150,Graphics.TOP|Graphics.LEFT);
           }
        }

        protected void keyPressed(int keyCode) {
            int action = this.getGameAction(keyCode);
            switch (action) {
            case Canvas.UP:
                index = 1;
                dis.setCurrent(fc);
                fc.repaint();
                break;
            case Canvas.DOWN:
                index = 2;
                
                dis.setCurrent(fc);
                fc.repaint();
                break;
            case Canvas.LEFT:
                index = 3;
                dis.setCurrent(fc);
                fc.repaint();
                break;
            case Canvas.RIGHT:
                index = 4;
                dis.setCurrent(fc);
                fc.repaint();
                break;
            case Canvas.FIRE:
                if (index == 1) {
                    rc.show();//没给出
                } else if (index == 2) {
                 tnc.show();//主要是给出的这个界面  点击来跳转到二级界面
                } else if (index == 3) {
                 hc.show();//没给出
                } else if (index == 4) {   
                 hec.show();//没给出
                }
                break;
            }
        }
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值