mainform.java

来自「手机在线系统 采用Java 中的J2ME, JSP 跟MySql 运行环」· Java 代码 · 共 176 行

JAVA
176
字号
/*
 * @(#)MainForm.java	1.11 01/08/23
 * Copyright (c) 2004-2005 wuhua of workroom Inc. All Rights Reserved.
 * @version 	1.0, 10/05/2004
 * @author 	饶荣庆
 * @author 	
 */
package com.j2me.main;

import com.j2me.phonebook.*;
import com.j2me.football.*;
import com.j2me.dictionary.*;
import com.j2me.recreation.*;
import com.j2me.language.*;
import com.j2me.counter.*;
import com.j2me.games.*;
import com.j2me.about.*;
import com.j2me.myphoto.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

/**
 *类MainForm是作为应用程序的主类。
 *并初始化了应用程序的启动一些元素
 */

public class MainForm extends MIDlet implements CommandListener
{
	public Display display = null;
	public LoginForm login = null;
	public MainList mainList = null;
	public LoginAlert loginAlert = null;
	public PhoneBookMenu phoneBookMenu = null;
	public MainFootballList football = null;
	public RecreationMenu recreation = null;
	public DictionaryMenu dictionary = null;
	public PhotoBookMenu photoBookMenu = null;
	public CounterForm counterForm = null;
	public GameMenu gameMenu = null;
	public LanguageForm languageForm = null;
	public About about = null;
	public Command okCommand = null;			//定义确定软键
	public Command exitCommand = null;			//定义离开软键

	/** 初始化应用程序*/
	public MainForm()
	{
		this.okCommand = new Command("确定", Command.OK, 2);
		this.exitCommand = new Command("离开", Command.EXIT, 2);
		this.mainList = new MainList();
		this.loginAlert = new LoginAlert("载入中...");
		this.phoneBookMenu = new PhoneBookMenu ("电话薄");
		this.football = new MainFootballList();
		this.photoBookMenu = new PhotoBookMenu("相册");
		this.counterForm = new CounterForm("计算器");// display, mainList);
		this.gameMenu = new GameMenu("游戏");
		this.languageForm = new LanguageForm("选择语言");//display, mainList);
		this.about = new About();
		this.mainList.addCommand(okCommand);
		this.mainList.addCommand(exitCommand);
		this.mainList.setCommandListener(this);
	}

	public void startApp()
	{
		this.display = Display.getDisplay(this);
		this.login = new LoginForm(display, loginAlert, mainList, this);
		this.display.setCurrent(login);
	}

	public void pauseApp()
	{}

    public void destroyApp(boolean unconditional)
	{}

	/*退出方法*/
	public void exit()
	{
		this.destroyApp(false);
		this.notifyDestroyed();
	}

	public void commandAction(Command c,Displayable s)
	{
		if(c==exitCommand)
		{
			exit();
		}
		else
		{
			int listIndex;
			listIndex = mainList.getSelectedIndex();	 //得到你所选择的是哪个菜单并作出响应, 你按下的是电话薄
			if (listIndex == 0)
			{
				phoneBookMenu.showForm(display, mainList);
			}

			if (listIndex == 1)
			{
				football.showForm(display, mainList);
			}
			if (listIndex == 2)
			{
				if (Language.isEnglish)
				{
					recreation = new RecreationMenu();
					recreation.setTitle("Recreation online");
					recreation.set(0, "Music online ", recreation.icon[0]);
					recreation.set(1, "News online", recreation.icon[1]);
					recreation.set(2, "Artist", recreation.icon[2]);

				}
				else
				{
					recreation = new RecreationMenu();
					recreation.setTitle("动感娱乐");
					recreation.set(0 ,"动感音乐", recreation.icon[0]);
					recreation.set(1, "新闻在线", recreation.icon[1]);
					recreation.set(2, "艺术家", recreation.icon[2]);
				}

				recreation.showForm(display, mainList);
				
			}

			if (listIndex == 3)
			{
				if (Language.isEnglish)
				{
					dictionary = new DictionaryMenu();
					dictionary.setTitle("Dictionary online");
					dictionary.set(0, "Find of English ", dictionary.icon[0]);
					dictionary.set(1, "Find of Chinese", dictionary.icon[1]);

				}
				else
				{
					dictionary = new DictionaryMenu();
					dictionary.setTitle("在线词典");
					dictionary.set(0 ,"用英语搜索", dictionary.icon[0]);
					dictionary.set(1, "用中文搜索", dictionary.icon[1]);
				}

				dictionary.showForm(display, mainList);
			}
			if (listIndex == 4)
			{
				photoBookMenu.showForm(display, mainList);
			}
			if (listIndex == 5)
			{
			}
			if (listIndex == 6)
			{
				counterForm.showForm(display, mainList);
			}
			if (listIndex == 7)
			{
				gameMenu.showForm(display, mainList);
			}
			if (listIndex == 8)
			{				
				languageForm.showForm(display, mainList);
				new Language(this, loginAlert, mainList, phoneBookMenu, football, photoBookMenu, 
					         counterForm, gameMenu, languageForm, about);
			}
			if (listIndex == 9)
			{
				about.showAbout(display);
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?