⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test4.java

📁 J2ME的源码!我以前学习J2ME的源码哈!非常适合初学者
💻 JAVA
字号:
package MidpDemo;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.media.control.ToneControl;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class Test4 extends MIDlet implements CommandListener {
	private Display display;

	private Form form;

	private Command cmdplay = new Command("播放", Command.OK, 3);

	private byte[] sequence;

	public Test4() {
		form = new Form("试验音频器");
		form.addCommand(cmdplay);
		form.setCommandListener(this);
		sequence = new byte[] { ToneControl.VERSION, 1, 67, 16, // The
				69, 16, // hills
				67, 8, // are
				65, 8, // a -
				64, 48, // live
				62, 8, // with
				60, 8, // the
				59, 16, // sound
				57, 16, // of
				59, 32, // mu -
				59, 32 // sic
		};
		display = display.getDisplay(this);
		display.setCurrent(form);
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {

	}

	protected void pauseApp() {

	}

	protected void startApp() throws MIDletStateChangeException {

	}

	public void commandAction(Command c, Displayable arg1) {

		try {
			Player player = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR);
			player.realize();
			ToneControl ta = (ToneControl) player.getControl("ToneControl");
			ta.setSequence(sequence);
			player.start();
		} catch (Exception e) {
			e.printStackTrace();

		}
	}

}

⌨️ 快捷键说明

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