J2ME中的TextBox
TextBox构造方法中的静态字段TextField.DECIMAL是怎么实现控制TextBox中的内容的?Java中通过静态字段实现控制好像用的很多具体怎么实现的呢?新...
TextBox构造方法中的静态字段TextField.DECIMAL是怎么实现控制TextBox中的内容的?
Java中通过静态字段实现控制好像用的很多 具体怎么实现的呢?
新手 麻烦说的尽量详细点
谢谢!! 展开
Java中通过静态字段实现控制好像用的很多 具体怎么实现的呢?
新手 麻烦说的尽量详细点
谢谢!! 展开
展开全部
这是源代码 具体怎么实现的我也不是很明白:期待高手解决
constraints 就是传递过来的那个参数
protected boolean buildInputModes(int constraints, int modifiers, String dMode, String[] aMode)
{
boolean ret = true;
this.capWord = (this.capSentence = 0);
if ((constraints == 2) || (constraints == 5) || (constraints == 3))
{
this.defaultMode = 3;
this.allowedModesNum = 1;
this.allowedModes[0] = 3;
}
else if ((constraints == 1) || (constraints == 4))
{
this.defaultMode = 2;
this.allowedModesNum = 4;
this.allowedModes[0] = 2;
this.allowedModes[1] = 1;
this.allowedModes[2] = 3;
this.allowedModes[3] = 4;
}
else {
if (constraints != 0) {
dMode = null;
aMode = null;
}
Vector uniqueModes = new Vector(NUM_INPUT_MODES);
if ((dMode == null) && (aMode == null)) {
this.allowedModesNum = this.supportedInputModes.length;
System.arraycopy(this.supportedInputModes, 0, this.allowedModes, 0, this.allowedModesNum);
this.defaultMode = this.allowedModes[0];
} else {
if ((dMode == null) && (aMode != null)) {
dMode = aMode[0];
}
if ((dMode != null) && (aMode == null)) {
aMode = new String[this.supportedCharSubset.length];
System.arraycopy(this.supportedCharSubset, 0, aMode, 0, this.supportedCharSubset.length);
}
for (int i = 0; i < this.inputModeConvTable.length; ++i) {
if (!(((String)this.inputModeConvTable[i][0]).equals(dMode)))
continue;
this.defaultMode = ((Integer)this.inputModeConvTable[i][1]).intValue();
break;
}
for (int j = 0; j < this.inputModeConvTable.length; ++j) {
for (int i = 0; i < aMode.length; ++i) {
Integer imode = (Integer)this.inputModeConvTable[i][1];
if ((!(((String)this.inputModeConvTable[j][0]).equals(aMode[i]))) || (uniqueModes.indexOf(imode) != -1))
continue;
uniqueModes.addElement(imode);
}
}
this.allowedModesNum = uniqueModes.size();
for (int i = 0; i < this.allowedModesNum; ++i) {
this.allowedModes[i] = ((Integer)uniqueModes.elementAt(i)).intValue();
}
if (this.defaultMode == 0) {
this.defaultMode = this.allowedModes[0];
}
}
this.capWord = ((modifiers & 0x100000) == 1048576);
this.capSentence = ((modifiers & 0x200000) == 2097152);
if ((this.capWord) || (this.capSentence)) {
this.defaultMode = 1;
}
}
this.oldInputMode = this.defaultMode;
this.inputMode = this.defaultMode;
return ret;
}
constraints 就是传递过来的那个参数
protected boolean buildInputModes(int constraints, int modifiers, String dMode, String[] aMode)
{
boolean ret = true;
this.capWord = (this.capSentence = 0);
if ((constraints == 2) || (constraints == 5) || (constraints == 3))
{
this.defaultMode = 3;
this.allowedModesNum = 1;
this.allowedModes[0] = 3;
}
else if ((constraints == 1) || (constraints == 4))
{
this.defaultMode = 2;
this.allowedModesNum = 4;
this.allowedModes[0] = 2;
this.allowedModes[1] = 1;
this.allowedModes[2] = 3;
this.allowedModes[3] = 4;
}
else {
if (constraints != 0) {
dMode = null;
aMode = null;
}
Vector uniqueModes = new Vector(NUM_INPUT_MODES);
if ((dMode == null) && (aMode == null)) {
this.allowedModesNum = this.supportedInputModes.length;
System.arraycopy(this.supportedInputModes, 0, this.allowedModes, 0, this.allowedModesNum);
this.defaultMode = this.allowedModes[0];
} else {
if ((dMode == null) && (aMode != null)) {
dMode = aMode[0];
}
if ((dMode != null) && (aMode == null)) {
aMode = new String[this.supportedCharSubset.length];
System.arraycopy(this.supportedCharSubset, 0, aMode, 0, this.supportedCharSubset.length);
}
for (int i = 0; i < this.inputModeConvTable.length; ++i) {
if (!(((String)this.inputModeConvTable[i][0]).equals(dMode)))
continue;
this.defaultMode = ((Integer)this.inputModeConvTable[i][1]).intValue();
break;
}
for (int j = 0; j < this.inputModeConvTable.length; ++j) {
for (int i = 0; i < aMode.length; ++i) {
Integer imode = (Integer)this.inputModeConvTable[i][1];
if ((!(((String)this.inputModeConvTable[j][0]).equals(aMode[i]))) || (uniqueModes.indexOf(imode) != -1))
continue;
uniqueModes.addElement(imode);
}
}
this.allowedModesNum = uniqueModes.size();
for (int i = 0; i < this.allowedModesNum; ++i) {
this.allowedModes[i] = ((Integer)uniqueModes.elementAt(i)).intValue();
}
if (this.defaultMode == 0) {
this.defaultMode = this.allowedModes[0];
}
}
this.capWord = ((modifiers & 0x100000) == 1048576);
this.capSentence = ((modifiers & 0x200000) == 2097152);
if ((this.capWord) || (this.capSentence)) {
this.defaultMode = 1;
}
}
this.oldInputMode = this.defaultMode;
this.inputMode = this.defaultMode;
return ret;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询