锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
http://code.google.com/speed/articles/
]]>
]]>
]]>
]]>try {
2 byte[] imgData = new byte[512];
3 InputStream in = Class.forName("BBUIApp").getResourceAsStream("1.jpg");
4 ByteArrayOutputStream bos = new ByteArrayOutputStream();
5 int count = -1;
6 while((count = in.read(imgData)) != -1)
7 {
8 bos.write(imgData, 0 , count);
9 }
10 byte[] img = bos.toByteArray();
11 bos.close();
12 in.close();
13 EncodedImage image = EncodedImage.createEncodedImage(img, 0, img.length);
14 image.setScale(2);
15 BitmapField f = new BitmapField();
16 f.setImage(image);
17 this.add(f);
18 } catch (Exception e) {
19
20 }
]]>public static Image createThumbnail(Image image,int width) {
int sourceWidth = image.getWidth();
int sourceHeight = image.getHeight();
int thumbWidth = width;
int thumbHeight = -1;
if (thumbHeight == -1)
thumbHeight = thumbWidth * sourceHeight / sourceWidth;
Image thumb = Image.createImage(thumbWidth, thumbHeight);
Graphics g = thumb.getGraphics();
for (int y = 0; y < thumbHeight; y++) {
for (int x = 0; x < thumbWidth; x++) {
g.setClip(x, y, 1, 1);//璁劇疆璇ュ儚绱犵偣浠ュ鐨勫尯鍩熺粯鍒舵棤鏁?/span>
int dx = x * sourceWidth / thumbWidth;
int dy = y * sourceHeight / thumbHeight;
g.drawImage(image, x - dx, y - dy,Graphics.LEFT | Graphics.TOP);//閲嶇粯鏁村紶鍥撅紝瀹為檯涓婂彧鏄噸緇樹簡涓涓儚绱犵偣
}
}
return thumb;
}
涓婇潰鐨勪唬鐮佺敤鏉ュ湪J2ME涓粯鍒跺浘鐗囩殑緙╃暐鍥撅紝CLDC1.0鐨勭敤娉曪紝2.0鍙互鐩存帴鎿嶆帶鍍忕礌浜?
]]>
public static final int KEY_SOFT2=112;//鍙抽敭 閿洏涓婇潰P
public static final int KEY_UP=1;//鐞冧笂
public static final int KEY_DOWN=6;//鐞冧笅
public static final int KEY_LEFT=2;//鐞冨乏
public static final int KEY_RIGHT=5;//鐞冨彸
public static final int KEY_OK=-8;//鐞冩寜涓?/p>
]]>/**
* MidletSample.java
*
* (c) Research In Motion Limited, 2003-2004. Confidential and proprietary.
*/
import java.util.*;
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.lang.*;
/**
* An Example MIDlet.
* The application must extend the MIDlet class to allow the application management software to control the MIDlet.
*/
public class MidletSample extends MIDlet implements CommandListener
{
private Display display;
/**
* <p>The default constructor. Say hello world
*/
public MidletSample()
{
//create a simple screen
// Form form = new Form("Hello Form");
// form.append( new StringItem( "Hello World", null ) );
// Command back = new Command("Back", Command.BACK, 0);
// form.addCommand(back);
// form.setCommandListener(this);
// Display.getDisplay(this).setCurrent(form);
this.display = Display.getDisplay(this);
MainCanvas main = new MainCanvas(this);
Show(main);
}
public void Show(Displayable d)
{
display.setCurrent(d);
}
/**
* <p>Signals the MIDlet that it has entered the Active state.
*/
public void startApp()
{
}
/**
* <p>Signals the MIDlet to stop and enter the Pause state.
*/
public void pauseApp()
{
}
/**
* <p>Signals the MIDlet to terminate and enter the Destroyed state.
* @param unconditional When set to true, the MIDlet must cleanup and release all resources. Otherwise, the MIDlet may
* throw a MIDletStateChangeException to indicate it does not want to be destroyed at this time.
*/
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c, Displayable d) {
// TODO Auto-generated method stub
if(c.getCommandType() == Command.BACK)
this.notifyDestroyed();
}
}
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
public class MainCanvas extends Canvas {
private MidletSample midletSample = null;
public MainCanvas(MidletSample midletSample)
{
this.midletSample = midletSample;
}
protected void paint(Graphics g) {
// TODO Auto-generated method stub
}
public void keyPressed(int key){
Alert al = new Alert(String.valueOf(key));
al.setTimeout(5000);
midletSample.Show(al);
}
}
]]>
鍒╃敤 RIM Blackberry JDE 4.1錛屾偍鐜板湪鍙互浣跨敤 NetBeans Mobility Pack 5.0 鏋勫緩 Blackberry 璁懼鐨?Java ME 搴旂敤紼嬪簭銆傜幇鍦ㄥ垎姝ヨ鏄庡浣曞紑濮嬫搷浣滐細
1. 涓嬭澆騫跺畨瑁?NetBeans IDE銆傜劧鍚庝笅杞藉茍瀹夎 NetBeans Mobility Pack銆傛渶鍚庯紝涓嬭澆騫跺畨瑁?RIM BlackBerry JDE 4.1.IDE銆傛偍灝嗕細鐢ㄥ埌璇?IDE錛屽洜涓哄疄鐢ㄥ伐鍏鋒槸闅?JDE 鑰屼笉鏄殢妯℃嫙鍣ㄥ垎甯冦?
2. 灝?RIM 娣誨姞涓鴻嚜瀹氫箟妯℃嫙鍣細
瀹屾垚璇ユ楠ゅ悗闇瑕侀噸鏂板惎鍔?NetBeans IDE銆?/strong>
3. 閫氳繃浠?Mobile 綾誨埆閫夋嫨 Mobile Application 閫夐」鍙互鍒涘緩鏂伴」鐩紝渚嬪 MobileApplication2銆?
4. 浣跨敤 Explorer 鐨?File 閫夐」鍗″茍鎵撳紑欏圭洰鐨?build.xml 鏂囦歡銆傚皢浠ヤ笅浠g爜鐗囨娣誨姞鍒?</project> 涔嬪墠錛?
<property name="rim.blackberry.home" location="C:\Program Files\Research In Motion\BlackBerry JDE 4.1.0"/> <property name="rim.blackberry.emulator" value="7250"/> <property name="rim.blackberry.jdwp.port" value="8000"/> <target name="post-jar"> <exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows XP" dir="${dist.root.dir}" executable="${rim.blackberry.home}/bin/rapc.exe" failonerror="true" resolveExecutable="true"> <arg value="import=${rim.blackberry.home}/lib/net_rim_api.jar"/> <arg value="codename=${name}"/> <arg value="-midlet"/> <arg value="jad=${dist.jad}"/> <arg value="${dist.jar}"/> </exec> <copy file="${name}.alx" todir="${dist.root.dir}"/> </target> <target name="run" depends="init,jar"> <copy todir="${rim.blackberry.home}/simulator" verbose="true"> <fileset dir="${dist.root.dir}"> <include name="**/${name}.*"/> </fileset> </copy> <exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows XP" dir="${rim.blackberry.home}/simulator" executable="${rim.blackberry.home}/simulator/${rim.blackberry.emulator}.bat" failonerror="true" resolveExecutable="true"/> </target> <target name="debug" depends="init,jar"> <copy todir="${rim.blackberry.home}/simulator" verbose="true"> <fileset dir="${dist.root.dir}"> <include name="**/${name}.*"/> </fileset> </copy> <delete file="${preprocessed.dir}/.timestamp"/> <parallel> <property name="jpda.port" value="${rim.blackberry.jdwp.port}"/> <java jar="${rim.blackberry.home}/bin/JDWP.jar" fork="true" dir="${rim.blackberry.home}/bin"> <jvmarg value="-Xmx128M"/> </java> <sequential> <sleep seconds="5"/> <antcall target="nbdebug"/> </sequential> </parallel> </target> <target name="post-clean"> <echo>Post clean</echo> <delete> <fileset dir="${rim.blackberry.home}/simulator"> <include name="**/${name}.*"/> </fileset> </delete> </target>
5. 浠?Files 閫夐」鍗′腑鍒涘緩涓涓悕涓?<name_of_the_project>.alx 鐨勬柊 Empty 鏂囦歡錛屽茍浣垮叾鎼哄甫浠ヤ笅鍐呭瀛樺叆欏圭洰鏂囦歡澶癸紙涓?build.xml 鎵鍦ㄧ殑鐩綍鍚岀駭錛侊級銆傚綋鐒訛紝鍙互鏇存敼鍚嶇О鏉ュ弽搴旀偍鐨勫簲鐢ㄧ▼搴忋傝繖鏄?Blackberry 璁懼璇嗗埆搴旂敤紼嬪簭璇︾粏淇℃伅鎵闇鐨勭壒孌婃枃浠躲?
<loader version="1.0"> <application id="MobileApplication2"> <name > </name> <description > </description> <version > </version> <vendor > MyCompany </vendor> <copyright > Copyright (c) 2005 MyCompany </copyright> <fileset Java="1.5"> <directory > MyCompany </directory> <files > MobileApplication2.cod </files> </fileset> </application> </loader>6. 鐜板湪錛屾偍宸茬粡鍑嗗瀹屾瘯錛屽彲浠ョ紪鍐欎唬鐮併佹瀯寤恒佽繍琛屻佹墽琛屽拰璋冭瘯浜嗐傚鏋滀嬌鐢?a target="new">姝?/a>浠g爜鐗囨鑰屼笉鏄楠?4 涓殑浠g爜鐗囨鏉ヤ慨琛?build.xml 鏂囦歡錛岄偅涔堟偍鐢氳嚦鍙互涓虹壒瀹氱殑欏圭洰閰嶇疆璁劇疆 RIM 鎵ц/璋冭瘯銆備絾鏄紝榪欏繀欏誨湪浣跨敤榪欎釜鐗囨錛圱est 鏄厤緗悕縐幫級鐨?build.xml 鏂囦歡涓墽琛岋細
<target name="init.rim.blackberry" depends="init"> <condition property="rim.blackberry" value="true"> <or> <equals arg1="Test" arg2="${config.active}"/> </or> </condition> </target>娉ㄦ剰錛氫竴鏃﹀紑濮嬫瀯寤洪」鐩拰鍚姩浠跨湡鍣紝灝遍渶瑕佹粴鍔ㄥ埌搴旂敤紼嬪簭鐨勫浘鏍囷紝璇ュ浘鏍囧湪浠跨湡鍣ㄦ墦寮鍚庝細鏄劇ず鍦ㄧЩ鍔ㄧ數璇濅富灞忓箷涓娿傛偍鍙互浣跨敤鏂瑰悜閿垨鍗曞嚮浠跨湡鍣ㄥ浘鍍忎笂鐨勬粴杞鑸埌搴旂敤紼嬪簭鍥炬爣銆?/em>
涓婃枃絎洓閮ㄥ垎娣誨姞build.xml鐨勪唬鐮佹椂璇鋒敞鎰忓皢location鏀規垚浣犳満鍣ㄤ笂鐨凧DE鍦板潃,location="C:\Program Files\Research In Motion\BlackBerry JDE 4.7.0"/>
鍙﹀<arg value="-midlet"/>榪欒濡傛灉寮鍙戠殑鏄敤blackberry UiApplication鐨勫簲璇ュ幓闄?鍚﹀垯灝嗕細鐢╩obility涓殑midlet,涓嶇煡閬撹繖鏍瘋瀵逛笉瀵?瀹為檯鎿嶄綔榪囩▼涓氨鏄笉闄ゅ幓鐨勮瘽,鐩存帴鍦˙B涓姤閿檍vm104.
鍓嶄竴孌墊椂闂磖im鎺ㄥ嚭浜哹old 9000鐨勬ā鎷熷櫒銆傝鎴戜滑鍙互鎰熷彈9000鐨勯瓍鍔涳紝瓚呭ぇ鐨勫垎杈ㄧ巼錛岀湡鐨勮浜鴻祻蹇冩偊鐩紱鏃犳硶澶氫漢閮介亣鍒頒簡鏃犳硶妯℃嫙涓婄綉鐨勯棶棰橈紝涓昏琛ㄧ幇鍦細闄勫甫鐨勬柊MDS鎵撳紑鍚庣獥鍙d竴闂嵆閫濄?br />
浜庢槸鏈漢鎼滅儲浜嗙浉鍏寵祫鏂欙紝騫墮『鍒╄В鍐充簡鎴戦亣鍒扮殑榪欎釜闂錛?br />
闂鐨勭棁緇撳湪浜嶣old9000闇瑕佽嚦灝慾dk1.6鐨勬敮鎸侊紝浠ュ線8800涔嬬被鐨勬ā鎷熷櫒鍙渶瑕?.5宸﹀彸鐨勫嵆鍙紱
瑙e喅姝ラ寰堢畝鍗曪細
1錛夊幓java瀹樻柟緗戠珯涓嬭澆涓涓渶鏂扮殑1.6鐗堟湰浠ュ強浠ヤ笂鐨刯dk騫跺畨瑁咃紝璁頒綇瀹夎璺緞錛屼笅杞?a >鐐瑰嚮榪欓噷錛?br />
2錛夊厜瀹夎榪樹笉琛岋紝榪樺緱淇敼鏈満鐨勭幆澧冨彉閲忥細
鎴戠殑鐢佃剳鈥斺斿睘鎬р斺旈珮綰р斺旂幆澧冨彉閲忥紝鏈変袱涓柟妗嗭紝鎵懼埌涓嬮潰緋葷粺鍙橀噺鏂規閲岄潰鐨凧AVA_HOME錛屼慨鏀瑰悗闈㈢殑鍊煎埌鍒氭墠瀹夎鐨凧DK鐨勮礬寰勶細褰㈠C:\Program Files\Java\jdk1.6.0_11錛屼箣鍚庨噸鍚満鍣紱
濂戒簡錛屽ぇ鍔熷憡鎴愶紝鐪嬬湅MDS鏄惁鍙互鍚姩浜嗭紝鍚姩姝e父鍚庯紝鎵撳紑bold嫻忚鍣紝鏁插叆緗戝潃錛岃澆鍏ユ甯革紝鎴戠殑闂鍒拌繖閲屽氨宸茬粡瑙e喅浜嗐?br />
鍏充簬涓枃鏄劇ず鐨勯棶棰?br />
鍙互鎼滅儲\Research In Motion\BlackBerry JDE 4.5.0\simulator\Java涓嬮潰鎵鏈夌殑鍖呭惈chinese鎴栬匷H_CN鐨刢od鏂囦歡錛岀劧鍚庡湪鎵撳紑妯℃嫙鍣ㄧ殑鏃跺欓夋嫨Load Java Program榪涜鍔犺澆灝卞彲浠ヤ簡銆?br />
銆愯漿甯栥戞潵鑷?http://gceclub.sun.com.cn/NetBeans/tutorials/mobility/blackberry.html