textviewermidlet.java
来自「textviewer 一个手机上的文本浏览器实现」· Java 代码 · 共 88 行
JAVA
88 行
package textViewer;import javax.microedition.lcdui.*;import javax.microedition.midlet.*;import java.io.InputStream;// import java.io.DataInputStream;import java.io.InputStreamReader;import java.lang.*;import java.util.Vector;import midletLib.*;public class textViewerMIDlet extends MIDlet implements ResourceIncrementLoadedListener { // startApp and destroyApp can throw a MIDletStateChangeException if they want private Display display; private TextViewerForm textViewerForm; private String text; private StringLoadThread stringLoadThread; public textViewerMIDlet() { // should anything go here???? textViewerForm = new TextViewerForm("Text Viewer", "hello katherine", this); stringLoadThread = new StringLoadThread(getClass().getResourceAsStream("text.1.txt"), this, null, this, 15, textViewerForm.getTextChunkLength()); //TODO: constant stringLoadThread.start(); // stringLoadThread.run(); } protected void startApp() { // textViewerForm.setText(text); // textViewerForm = new TextViewerForm("Text Viewer", "text test"); display = Display.getDisplay(this); display.setCurrent(textViewerForm); } protected void pauseApp( ) { } protected void destroyApp( boolean unconditional ) { } public void resourceLoaded(Object rsrcID, Object rsrc) { // there is only one thing we could be waiting for... textStringLoaded((String)rsrc); } public void moreOfResourceLoaded(Object rsrcID, Object rsrc) { // there is only one thing we could be waiting for... moreOfTextStringLoaded((String)rsrc); } private void textStringLoaded(String text) { this.text = text; textViewerForm.setText(text); try { this.stringLoadThread.join(); } catch (InterruptedException e) {} //TODO: handle this.stringLoadThread = null; //so gc can get it System.gc(); } public void moreOfTextStringLoaded(String text) { this.text = text; textViewerForm.setText(text); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?