📄 jmtextfield.java.svn-base
字号:
super.enableInputMethods(true);
} // END IF
super.processFocusEvent(aoEvent);
} // END processFocusEvent(FocusEvent)
/**
* replaceSelection
* 僥僉僗僩僼傿乕儖僪偵擖椡偝傟偨暥帤楍偺僠僃僢僋偲憓擖張棟傪峴偆丅
* @param asDestination : 僥僉僗僩僼傿乕儖僪偵擖椡偝傟偨暥帤楍
*/
public void replaceSelection(String asDestination) {
//擖椡嫅斲暥帤楍偺僠僃僢僋
if (piRefusalMode != REFUSAL_NONE) {
//堷悢asDestination偵piRefusalMode偵堦抳偡傞暥帤楍偑懚嵼偡傞偐僠僃僢僋偡傞丅
String psReVal = "" + phRefusal.get("" + piRefusalMode);
if (mChkStr(psReVal).equals("")) {
return;
} // END IF
if (piImeMethod == IME_OFF) {
if (JMCheck.isZen(asDestination)) {
return;
} // END IF
}
if (asDestination == null)
{
if (this.getSelectionEnd() != this.getSelectionStart()) {
super.replaceSelection(asDestination);
} // END IF
return;
} // END IF
for (int m = 0; m < psReVal.length(); m++) {
char psStr = psReVal.charAt(m);
//慡妏暥帤偺擖椡傪嫅斲
if (psStr == '1') {
for (int n = 0; n < asDestination.length(); n++) {
if ( ("" + asDestination.charAt(n)).getBytes().
length == 2) {
return;
} // END IF
} // END FOR
} // END IF
//敿妏悢帤偺擖椡傪嫅斲
if (psStr == '2') {
if (!JMCheck.isNumAlpha(asDestination)) {
return;
} // END IF
} // END IF
//敿妏塸帤偺擖椡傪嫅斲
if (psStr == '4') {
if (!JMCheck.isEngAlpha(asDestination)) {
return;
} // END IF
} // END IF
//敿妏婰崋偺擖椡傪嫅斲
if (psStr == '8') {
if (mChkSignAlpha(asDestination)) {
return;
} // END IF
} // END IF
} // END FOR
} // END IF
int isel = this.getSelectionEnd() - this.getSelectionStart();
int piLen = getLength();
if (piMaxLength != 0)
{
if (this.getSelectionStart() != this.getSelectionEnd())
{
if ( isel > 0 )
{
piLen = piLen -
(this.getSelectionEnd() - this.getSelectionStart());
}else
{
piLen = piLen -
(this.getSelectionStart() - this.getSelectionEnd());
}
} // END IF
//copy data in
if (!mChkStr(asDestination).equals("")) {
int piInv = -1;
if (piLengthMethod == LENGTH_BY_UNICODE) {
piInv = asDestination.length();
}
else {
piInv = asDestination.getBytes().length;
} // END IF
int pileft = piMaxLength - piLen;
if (piInv > pileft) {
piInv = pileft;
} // END IF
if (piInv > 0) {
if (piLengthMethod == LENGTH_BY_UNICODE) {
asDestination = asDestination.substring(0, piInv);
} else {
asDestination = new String( asDestination.getBytes(), 0, piInv );
}
} // END IF
} // END IF
} // END IF
if (piMaxLength == 0 || piLen < piMaxLength || isel == 1 || isel == -1) {
super.replaceSelection(asDestination);
} // END IF
} // END replaceSelection(String)
/**
* setIMEMethod
* IME偺惂屼曽朄傪愝掕偡傞丅
* @param aiImeMethod : IME偺惂屼曽朄傪巜掕偡傞丅惂屼曽朄偼師偺抣傪巜掕偡傞丅
* 抣 愢柧
* IME_NONE IME 惂屼傪摿偵峴傢側偄丅
* IME_ON 僼僅乕僇僗庢摼帪偵IME傪ON偵偡傞丅
* IME_OFF 僼僅乕僇僗庢摼帪偵IME 傪OFF偵偡傞丅
* @return boolean : 惉岟偺帪偵true傪曉傞丄堷悢偑晄惓側応崌偵false傪曉傞丅
*/
public boolean setIMEMethod(int aiImeMethod) {
if (aiImeMethod != IME_NONE &&
aiImeMethod != IME_ON &&
aiImeMethod != IME_OFF) {
return false;
} // END IF
piImeMethod = aiImeMethod;
return true;
} // END setIMEMethod(int)
/**
* setLengthMethod
* 暥帤楍挿偺敾掕曽朄傪愝掕偡傞丅
* @param aiLengthMethod : 暥帤楍偺敾掕曽朄傪巜掕偡傞丅敾掕曽朄偼師偺抣傪巜掕偡傞丅
* 抣 愢柧
* LENGTH_BY_UNICODE UNICODE 僉儍儔僋僞悢偵傛傝敾掕偡傞丅
* LENGTH_BY_NATIVE OS偺昗弨暥帤僙僢僩偵傛傞僶僀僩悢偵傛傝敾掕偡傞丅
* @return boolean : 惉岟偺帪偵true傪曉傞丄堷悢偑晄惓側応崌偵false傪曉傞丅
*/
public boolean setLengthMethod(int aiLengthMethod) {
if (aiLengthMethod != LENGTH_BY_UNICODE &&
aiLengthMethod != LENGTH_BY_NATIVE) {
return false;
} // END IF
piLengthMethod = aiLengthMethod;
return true;
} // END setLengthMethod(int)
/**
* setMaxLength
* 擖椡壜擻側嵟戝暥帤楍挿傪愝掕偡傞丅
* @param aiMaxLength : 嵟戝暥帤楍挿傪巜掕偡傞丅
* @return boolean : 惉岟偺帪偵true傪曉傞丄堷悢偑晄惓側応崌偵false傪曉傞丅
*/
public boolean setMaxLength(int aiMaxLength) {
if (aiMaxLength < 0) {
return false;
} // END IF
piMaxLength = aiMaxLength;
return true;
} // END setMaxLength(int)
/**
* setRefusalCharacterMode
* 擖椡嫅斲偡傞暥帤僙僢僩儌乕僪傪愝掕偡傞丅
* @param aiRefusalMode : 擖椡傪嫅斲偡傞暥帤僙僢僩儌乕僪傪巜掕偡傞丅
* 暥帤僙僢僩儌乕僪偼師偺抣偺慻傒崌傢偣偱巜掕偡傞丅
* 抣 愢柧
* REFUSAL_NONE 慡偰偺暥帤庬傪嫋壜偟偰偄傞丅
* REFUSAL_WIDE 慡妏暥帤偺擖椡傪嫅斲偟偰偄傞丅
* REFUSAL_NUMBER 敿妏悢帤偺擖椡傪嫅斲偟偰偄傞丅
* REFUSAL_ALPHABET 敿妏塸帤偺擖椡傪嫅斲偟偰偄傞丅
* REFUSAL_SYMBOL 敿妏婰崋偺擖椡傪嫅斲偟偰偄傞丅
* @return boolean : 惉岟偺帪偵true傪曉傞丄堷悢偑晄惓側応崌偵false傪曉傞丅
*/
public boolean setRefusalCharacterMode(int aiRefusalMode) {
if (aiRefusalMode < REFUSAL_NONE ||
aiRefusalMode > REFUSAL_WIDE + REFUSAL_NUMBER +
REFUSAL_ALPHABET + REFUSAL_SYMBOL) {
return false;
} // END IF
piRefusalMode = aiRefusalMode;
return true;
} // END setRefusalCharacterMode(int)
/**
* setReplaceMode
* 抲姺儌乕僪傪愝掕偡傞丅
* @param abMode : 抲姺儌乕僪傪巜掕偡傞丅抲姺儌乕僪偵偼師偺抣傪巜掕偡傞丅
*/
public void setReplaceMode(boolean abMode) {
pbReplaceMode = abMode;
} // END setReplaceMode(boolean)
/**
* mChkStr
* <PRE>
* 暥帤楍偑Null偐斲偐傪僠僃僢僋
* </PRE>
*
* @param asVal : 僠僃僢僋偡傞暥帤楍
* @return String : <code>Null</code>丄<code>"null"</code>丄<code>""</code>丂
* 偺応崌<code>""</code>丄偦偺懠応崌String傪曉傞
*/
private String mChkStr(String asVal) {
if (asVal == null) {
return "";
} // END IF
if (asVal.trim().equals("null")) {
return "";
} // END IF
if (asVal.trim().equals("")) {
return "";
} // END IF
return asVal.trim();
} // END mChkStr(String) {
/**
* ChkSignAlpha
* 敿妏婰崋僠僃僢僋
* @param asval : 僠僃僢僋偡傞暥帤楍
* @return true : YES ; false : NO
*/
private boolean mChkSignAlpha(String asval) {
final String psHanjh = " `~!@#$%^&*()_+|-=[]{}<>/?;':\"\\,.";
for (int i = 0; i < psHanjh.length(); i++) {
String pa = psHanjh.substring(i, i + 1);
int pis = asval.indexOf(pa);
if (pis != -1) {
return true;
} // END IF
} // END FOR
return false;
} // END ChkSignAlpha(String)
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -