KeyField.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
/*
* Copyright (C) 1996 Active Software, Inc.
* All rights reserved.
*
* @(#) KeyField.java 1.6 - last change made 05/02/97
*/
// commented out -kp use Event constants...
// public static final int ESC = 27;
// public static final int DELETE = 127;
private static int ipadx = 20;
private static int ipady = 14;
private int key;
private FontMetrics fontMetrics;
private boolean hasFocus;
public void addNotify() {
super.addNotify();
}
public void removeNotify() {
super.removeNotify();
fontMetrics = null;
}
public Dimension minimumSize() {
if (fontMetrics != null) {
"Carriage Return") + ipadx;
}
return d;
}
public Dimension preferredSize() {
return minimumSize();
}
repaint();
}
public int getKey() {
return key;
}
private String getKeyString() {
switch (key) {
case 0:
break;
case /* NOI18N */ '\n':
break;
case /* NOI18N */ '\t':
break;
case /* NOI18N */ '\f':
break;
case /* NOI18N */ '\r':
break;
// case /* NOI18N */ '\b':
case Event.BACK_SPACE:
break;
case /* NOI18N */ ' ':
break;
// case ESC:
break;
// case DELETE:
break;
/* added -kp */
break;
break;
break;
break;
case Event.PRINT_SCREEN:
break;
case Event.SCROLL_LOCK:
break;
/* end added -kp */
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
default:
if (key >= 32)
else
break;
}
return str;
}
g = getGraphics();
if (isEnabled())
g.setColor(getForeground());
else
g.drawString(str, x, y);
g.setColor(getBackground());
if (hasFocus) {
g.setColor(getForeground());
}
}
public boolean handleEvent(Event e) {
if (!hasFocus) {
hasFocus = true;
repaint();
}
if (hasFocus) {
hasFocus = false;
repaint();
}
} else {
return super.handleEvent(e);
}
return false;
}
if (!hasFocus)
requestFocus();
return false;
}
return false;
}
}