home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Graphics;
-
- class InputField {
- int maxchars = 50;
- int cursorPos;
- Applet app;
- String sval;
- char[] buffer;
- int nChars;
- int width;
- int height;
- Color bgColor;
- Color fgColor;
-
- public InputField(String var1, Applet var2, int var3, int var4, Color var5, Color var6) {
- this.width = var3;
- this.height = var4;
- this.bgColor = var5;
- this.fgColor = var6;
- this.app = var2;
- this.buffer = new char[this.maxchars];
- this.nChars = 0;
- if (var1 != null) {
- var1.getChars(0, var1.length(), this.buffer, 0);
- this.nChars = var1.length();
- }
-
- this.sval = var1;
- }
-
- public void setText(String var1) {
- for(int var2 = 0; var2 < this.maxchars; ++var2) {
- this.buffer[var2] = 0;
- }
-
- this.sval = new String(var1);
- if (var1 == null) {
- this.sval = "";
- this.nChars = 0;
- this.buffer[0] = 0;
- } else {
- this.sval.getChars(0, this.sval.length(), this.buffer, 0);
- this.nChars = var1.length();
- this.sval = new String(this.buffer);
- }
- }
-
- public String getValue() {
- return this.sval;
- }
-
- public void paint(Graphics var1, int var2, int var3) {
- var1.setColor(this.bgColor);
- var1.fillRect(var2, var3, this.width, this.height);
- if (this.sval != null) {
- var1.setColor(this.fgColor);
- var1.drawString(this.sval, var2, var3 + this.height / 2 + 3);
- }
-
- }
-
- public void mouseUp(int var1, int var2) {
- }
-
- public void keyDown(int var1) {
- if (this.nChars < this.maxchars) {
- switch (var1) {
- case 8:
- --this.nChars;
- if (this.nChars < 0) {
- this.nChars = 0;
- }
-
- this.buffer[this.nChars] = 0;
- this.sval = new String(new String(this.buffer));
- break;
- case 9:
- default:
- this.buffer[this.nChars++] = (char)var1;
- this.sval = new String(new String(this.buffer));
- break;
- case 10:
- this.selected();
- }
- }
-
- this.app.repaint();
- }
-
- public void selected() {
- }
- }
-