displayable1.java

来自「一个播放音乐的J2ME程序,已调试成功,在Eclipse环境下编写,由J2ME模」· Java 代码 · 共 54 行

JAVA
54
字号
//import javax.microedition.midlet.MIDlet;
//import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDletStateChangeException;

public  class Displayable1 extends Canvas implements CommandListener {
	playmusic p = new playmusic("/wozhuanqianle.midi");
	private Command exitCommand;
	public Displayable1() {
		exitCommand=new Command("Exit", Command.EXIT, 1);
		try {
		      jbInit();
		    }
		catch(Exception e) {
		      e.printStackTrace();
		    }		
	}

	private void jbInit() throws Exception {
	    // Set up this Displayable to listen to command events
	    setCommandListener(this);
	    // add the Exit command
	    addCommand(exitCommand);

	}

	public void commandAction(Command command, Displayable displayable) {
	    if (command == exitCommand) {
	// stop the MIDlet
	      try {
			MEvidio.quitApp();
		} catch (MIDletStateChangeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    }
	  }

	public void paint(Graphics g) {
	   
	    p.play(100,true);

	  }

	/*public void setExitCommand(Command exitCommand) {
		this.exitCommand = exitCommand;
	}

	public Command getExitCommand() {
		return exitCommand;
	}*/

}

⌨️ 快捷键说明

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