home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.plaf.basic;
-
- import java.awt.Component;
- import java.awt.event.FocusEvent;
- import java.awt.event.KeyEvent;
-
- public class StringSpinner extends Spinner {
- private String[] names;
- private String typed;
-
- public StringSpinner(int var1, String var2, String[] var3) {
- super(var1, var2);
- this.names = var3;
- ((Spinner)this).setMinimum(0);
- ((Spinner)this).setMaximum(var3.length - 1);
- ((Spinner)this).setWrap(true);
- ((Spinner)this).updateUI();
- }
-
- public String[] getNameArray() {
- return this.names;
- }
-
- public String getValueName() {
- return this.names[super.value];
- }
-
- public String getTypedString() {
- return this.typed;
- }
-
- private void resynctyped() {
- if (this.typed != null) {
- int var1 = this.typed.length();
-
- for(int var2 = 0; var2 < this.names.length; ++var2) {
- if (this.typed.regionMatches(true, 0, this.names[var2], 0, var1)) {
- ((Spinner)this).setValue(var2);
- ((Component)this).repaint();
- return;
- }
- }
-
- if (var1 > 1) {
- this.typed = this.typed.substring(0, var1 - 1);
- } else {
- this.typed = null;
- }
-
- this.resynctyped();
- }
-
- }
-
- public void keyPressed(KeyEvent var1) {
- if (var1.isActionKey()) {
- switch (var1.getKeyCode()) {
- case 38:
- ((Spinner)this).setValue(super.value + 1);
- return;
- case 39:
- default:
- break;
- case 40:
- ((Spinner)this).setValue(super.value - 1);
- return;
- }
- } else {
- char var2 = var1.getKeyChar();
- if (var2 > ' ' && var2 < 127) {
- this.typed = this.typed != null ? this.typed + (char)var2 : String.valueOf((char)var2);
- this.resynctyped();
- return;
- }
-
- switch (var2) {
- case '\b':
- case '\u007f':
- if (this.typed != null) {
- if (this.typed.length() <= 0) {
- this.typed = null;
- } else {
- this.typed = this.typed.substring(0, this.typed.length() - 1);
- }
- }
-
- this.resynctyped();
- return;
- }
- }
-
- }
-
- public void focusGained(FocusEvent var1) {
- this.typed = null;
- ((Component)this).repaint();
- super.focusGained(var1);
- }
-
- public void focusLost(FocusEvent var1) {
- this.typed = null;
- ((Component)this).repaint();
- super.focusLost(var1);
- }
- }
-