📄 myset.java
字号:
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import com.nokia.mid.ui.FullCanvas;
class MySet extends FullCanvas
{
static PlayMusic p;
private static Displayable instance;
private Image back;
private boolean soundOn = true;
// 创建并得到一个排行榜画面的对象
synchronized public static Displayable getInstance()
{
if(instance == null)
instance = new MySet();
return instance;
}
// 排行榜画面的构造方法,加入了2个按钮
private MySet()
{
setFullScreenMode(true);
p = new PlayMusic();
back = null;
try
{
back = Image.createImage("/res/back.png");
}
catch(Exception e)
{}
}
protected void keyPressed(int key)
{
switch(getGameAction(key))
{
case Canvas.UP:
soundOn = true;
MyMenu.musicON = true;
MyMenu.startMusic();
MyGame.musicON = true;
repaint();
break;
case Canvas.DOWN:
soundOn = false;
MyMenu.musicON = false;
MyMenu.p.Music_stop();
MyGame.musicON = false;
repaint();
break;
}
if (key == -7)
{
GameMenu.flow("返回");
}
}
//在帮助画面上写上说明文字
protected void paint(Graphics g)
{
g.setColor(0,0,0);
g.fillRect(0,0,getWidth(),getHeight());
if(soundOn)
{
g.setColor(255,255,0);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_PLAIN,Font.SIZE_LARGE));
g.drawString("声音开",getWidth()/2-20,getHeight()/2-20,Graphics.TOP|Graphics.LEFT);
g.setColor(255,255,128);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_PLAIN,Font.SIZE_SMALL));
g.drawString("声音关",getWidth()/2-20,getHeight()/2+20,Graphics.TOP|Graphics.LEFT);
}
else
{
g.setColor(255,255,128);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_PLAIN,Font.SIZE_SMALL));
g.drawString("声音开",getWidth()/2-20,getHeight()/2-20,Graphics.TOP|Graphics.LEFT);
g.setColor(255,255,0);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_PLAIN,Font.SIZE_LARGE));
g.drawString("声音关",getWidth()/2-20,getHeight()/2+20,Graphics.TOP|Graphics.LEFT);
}
g.drawImage(back,getWidth(),getHeight(),Graphics.BOTTOM|Graphics.RIGHT);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -