5776624 [rkeene@sledge /home/rkeene/archive/floydssh/telnet]$ cat -n InputDialog.java
 1 package telnet;

 2 
 3 import javax.microedition.lcdui.*;

 4 
 5 /* This file is part of "Telnet Floyd".
 6  *
 7  * (c) Radek Polak 2003-2004. All Rights Reserved.
 8  * The file was changed by Radek Polak to work as midlet in MIDP 1.0
 9  *
10  * Please visit project homepage at http://phoenix.inf.upol.cz/~polakr
11  *
12  * --LICENSE NOTICE--
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26  * --LICENSE NOTICE--
27  *
28  */
29 
30 /**
31  * User can use this dialog to enter specified text or special sequences like
32  * ctrl+d etc.. To invoke this special just enter "ctrl+d" or "ctrld".
33  */
34 
35 public class InputDialog extends TextBox implements CommandListener {
36   /**Construct the displayable*/
37   public InputDialog() {
38     super("", "", 1024, TextField.ANY);
39     setCommandListener(this);
40     addCommand(new Command("Enter", Command.OK, 1 ));
41     addCommand(new Command("Type", Command.ITEM, 2 ));
42   }
43 
44   /**Handle command events*/
45   public void commandAction(Command command, Displayable displayable) {
46     Telnet.setDisplay( (Displayable) Telnet.terminal);
47     String str = this.getString();
48     int modifiers = Telnet.terminal.getModifiers(str);
49     if (modifiers != 0) { // special keys - like ctrl+d

50       char keyChar = (char) (str.charAt(str.length() - 1) - 'a' + 1);
51       Telnet.emulation.keyTyped(0, keyChar, modifiers); // key identified by specific string (CTRL+x)

52     }
53     else {
54       for (int i = 0; i < str.length(); i++)
55         Telnet.emulation.keyTyped(0, str.charAt(i), 0);
56       if (command.getCommandType() == Command.OK)
57         Telnet.emulation.keyTyped(0, '\n', 0);
58     }
59   }
60 }
5776625 [rkeene@sledge /home/rkeene/archive/floydssh/telnet]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2004-03-06 22:44:06