?? myui.java
字號:
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class MyUI {
//定義一組表示界面顯示狀態的數值
public static final int UI_TITLE = 0; //顯示標題畫面
public static final int UI_HIDE = 1; //隱藏界面
public static final int UI_STATE_NUM = 2; //界面狀態總數
private int m_nState = UI_TITLE; //當前的界面狀態
private Image m_TitleImg; //標題畫面圖像
private MyButton m_Button; //按鈕對象
public MyUI( MyButton button ){
m_Button = button;
try{ //讀取標題圖像
m_TitleImg = Image.createImage("/demo/title.png");
}
catch (Exception ex){}
}
/*****
* 獲取當前的界面狀態
* @返回:當前界面狀態
*/
public int getState(){
return m_nState;
}
/*****
* 設置當前的界面狀態,并進行出錯處理
* @參數 nType.........要設置的狀態
*/
public void setState( int state ){
if( state < 0 || state >= UI_STATE_NUM )
return;
m_nState = state;
}
public MyButton getButton(){
return m_Button;
}
/*****
* 處理按鍵的輸入
* @參數 keyStates.....當前的按鍵狀態
* @返回所選按鈕的類型
*/
public int Input( int keyStates ){
int type = -1;
switch( m_nState ){
case UI_TITLE:
type = m_Button.Input(keyStates);
break;
case UI_HIDE:
break;
}
return type;
}
/*****
* 顯示界面內容
* @參數 g.............對應顯示屏幕
* @參數 scrWidth......屏幕的寬
* @參數 scrHeight.....屏幕的高
*/
public void Paint( Graphics g, int scrWidth, int scrHeight ){
int x = scrWidth;
int y = scrHeight;
switch( m_nState ){
case UI_TITLE: //顯示標題畫面
if( m_TitleImg != null ){
x = ( x - m_TitleImg.getWidth() ) / 2;
y = ( y - m_TitleImg.getHeight() ) / 2;
g.drawImage(m_TitleImg, x, y, 0 );
}
m_Button.Paint(g, scrWidth, scrHeight);
break;
case UI_HIDE: //隱藏界面
break;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -