📄 emmenuform.java
字号:
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov Date: 2005-4-3 23:29:11
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: EMMenuForm.java
package NBMaJiang;
import com.nokia.mid.ui.FullCanvas;
import java.util.Vector;
import javax.microedition.lcdui.*;
// Referenced classes of package NBMaJiang:
// Action, ActionListener
public class EMMenuForm extends FullCanvas
{
public EMMenuForm()
{
init();
}
private void init()
{
menuActions = new Vector();
width = getWidth();
height = getHeight();
smallFont = Font.getFont(0, 0, 8);
curIndex = 1;
try
{
backImg = Image.createImage("/NBMaJiang/images/backImage.png");
bgImg = Image.createImage("/NBMaJiang/images/bgImage.png");
arrowImg = Image.createImage("/NBMaJiang/images/arrow.png");
}
catch(Exception e) { }
}
protected void paint(Graphics g)
{
drawBg(g);
drawMenu(g);
}
private void drawBg(Graphics g)
{
g.drawImage(bgImg, 0, 0, 0x10 | 4);
}
private void drawMenu(Graphics g)
{
int per = (height - 25) / (menuActions.size() * 2);
g.setFont(smallFont);
for(int i = 0; i < menuActions.size(); i++)
{
int tX = 30;
int tY = (2 * i + 1) * per;
if(curIndex == i + 1)
g.drawImage(backImg, 20, tY - 2, 0x10 | 4);
g.setColor(0);
g.drawString(((Action)menuActions.elementAt(i)).getLabel(), tX + 5, tY + 2, 0x10 | 4);
}
g.setClip(width - 27, height - 38, 18, 30);
g.drawImage(arrowImg, width - 27, height - 38, 0x10 | 4);
if(okAction == null)
okAction = new Action("\u9009\u62E9", 5, 1);
}
public void setMenuItem(Action item)
{
menuActions.addElement(item);
}
private void setCommandAction(Action item)
{
okAction = item;
}
protected void keyPressed(int keyCode)
{
if(keyCode == -7)
{
if(okAction.type == 5 && actionListener != null)
actionListener.action((Action)menuActions.elementAt(curIndex - 1), this);
return;
}
int action = getGameAction(keyCode);
switch(action)
{
default:
break;
case 1: // '\001'
curIndex--;
if(curIndex < 1)
curIndex = menuActions.size();
break;
case 6: // '\006'
curIndex++;
if(curIndex > menuActions.size())
curIndex = 1;
break;
}
repaint();
}
public void setActionListener(ActionListener actListener)
{
actionListener = actListener;
}
private Action okAction;
private Vector menuActions;
private ActionListener actionListener;
private Font smallFont;
private int curIndex;
private int width;
private int height;
private Image bgImg;
private Image backImg;
private Image arrowImg;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -