📄 setform.java
字号:
// ViewForm.java// Copyright by Versitech Ltd.// All rights reservedimport javax.microedition.lcdui.*;import javax.microedition.rms.RecordStore;public class SetForm extends Form implements Runnable { private GalaxyWarCanvas sampleGame; private RecordStore rs; private TextField useridField, mobileField; private StringItem errorInfo; // Please change the following parameters accordingly private String userid = "default"; private String mobile = "8613800000000"; public SetForm (GalaxyWarCanvas sampleGame) { super("Auto Upload Setting"); this.sampleGame = sampleGame; errorInfo = new StringItem("",sampleGame.ERRORINFO2); String info = readUploadSetting(); if (info.length() > 1) { userid = info.substring(0,info.indexOf(",")); mobile = info.substring(info.indexOf(",") + 1,info.length()); System.out.println("userid:" + userid); } useridField = new TextField("User ID", userid, 20, TextField.ANY); mobileField = new TextField("Mobile", mobile, 20, TextField.PHONENUMBER); append(useridField); append(mobileField); append(errorInfo); //addCommand(GalaxyWarCanvas.exitCommand); addCommand(GalaxyWarCanvas.setCommand); addCommand(GalaxyWarCanvas.backCommand); setCommandListener(sampleGame); GalaxyWarCanvas.display.setCurrent(this); } void start(){ Thread t = new Thread(this); try { t.start(); } catch(Exception e){} } public void run() { updateUploadSetting(); } private void updateUploadSetting () { byte[] rec; String info = useridField.getString() + "," + mobileField.getString(); sampleGame.userID = useridField.getString(); sampleGame.mobile = mobileField.getString(); try { rs = RecordStore.openRecordStore("galaxywar",false); rec = info.getBytes(); rs.setRecord(3,rec,0,rec.length); rs.closeRecordStore(); } catch (Exception ex) { System.out.println("scoreUpload setting: " + ex); } } private String readUploadSetting(){ byte[] rec; String result = ""; try { rs = RecordStore.openRecordStore("galaxywar",false); rec = new byte[300]; rs.getRecord(3,rec,0); rs.closeRecordStore(); if (rec[0] != 0) result = new String(rec); } catch (Exception ex) { System.out.println("readUploadSetting: " + ex); } return result.trim(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -