urlcodebox.java~
来自「KeePass for J2ME is a J2ME port of KeePa」· JAVA~ 代码 · 共 109 行
JAVA~
109 行
package org.phoneid.keepassj2me;// PhoneID utilsimport org.phoneid.*;// Javaimport java.io.*;import javax.microedition.lcdui.*;import javax.microedition.midlet.*;public class PasswordBox implements CommandListener{ protected KeePassMIDlet midlet; private boolean isReady = false; private Displayable dspBACK; private String result = null; private Form form = null; private TextField txtField = null; private int mCommandType = 0; /** * title : title of entire window * boxTitle : title of text enter field * defaultValue : default value of text enter field * maxLen : max length of text enter field * midlet : parent MIDlet object * returnToPrevScreen : return to previous screen when the task is done * type : TextField.NUMERIC, TextField.PASSWORD, etc. * thirdButton : put a string if you want to have the third button after OK and CANCEL * comment : comment about third button */ public PasswordBox(String title, String boxTitle, String defaultValue, int maxLen, KeePassMIDlet midlet, boolean returnToPrevScreen, int type, String thirdButton, String comment) { //System.out.println ("PasswordBox 1"); form = new Form(title); this.midlet = midlet; //System.out.println ("PasswordBox 2: " + defaultValue); txtField = new TextField(boxTitle, defaultValue, maxLen, type); //System.out.println ("PasswordBox 3"); form.append(txtField); //System.out.println ("PasswordBox 4"); form.setCommandListener(this); form.addCommand(new Command("OK", Command.OK, 1)); form.addCommand(new Command("Cancel", Command.CANCEL, 1)); if (thirdButton != null) form.addCommand(new Command(thirdButton, Command.ITEM, 1)); if (comment != null) form.append(comment); // Previous Display dspBACK = Display.getDisplay(midlet).getCurrent(); // Set Display Display.getDisplay(midlet).setCurrent(form); // wait for it to be done waitForDone(); // Return the the previous display if (returnToPrevScreen == true) Display.getDisplay(midlet).setCurrent(dspBACK); } private void waitForDone() { try { while(!isReady) { synchronized(this) { this.wait(); } } } catch(Exception e) { } } public void commandAction(Command cmd, Displayable dsp) { mCommandType = cmd.getCommandType(); if(cmd.getCommandType() == Command.OK || cmd.getCommandType() == Command.CANCEL || cmd.getCommandType() == Command.ITEM) { if(cmd.getCommandType() == Command.OK) result = txtField.getString(); else result = null; isReady = true; synchronized(this) { this.notify(); } } } public String getResult() { return result; } public int getCommandType() { return mCommandType; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?