gpt4 book ai didi

java-me - LWUIT TextArea 问题

转载 作者:行者123 更新时间:2023-12-02 02:22:45 24 4
gpt4 key购买 nike

有什么方法可以在不进入 LCDUI 窗口的情况下在 textArea 中写入内容?我想在我的 LWUIT 应用程序中编辑我的 textArea,但每次我尝试这样做时,该应用程序都会将我发送到 LCDUI 窗口。

最佳答案

要禁用 LWUIT 编辑控件触发器,您可以使用以下代码。

textArea.setNativeTextboxTrigger(false);

需要在LWUIT TextArea源码中实现如下代码

static final String CLIENT_PROPERTY_FIRE_ACTION_TIMES = "FIRE-ACTION-TIMES";
static final String CLIENT_PROPERTY_DEAFULT_TEXT = "DEFAULT-TEXT";


public void setNativeTextboxTrigger(boolean enable) {
registerNativeTextboxTriggerEvent = enable;

static final String CLIENT_PROPERTY_FIRE_ACTION_TIMES = "FIRE-ACTION-TIMES";
static final String CLIENT_PROPERTY_DEAFULT_TEXT = "DEFAULT-TEXT";
try {
if( registerNativeTextboxTriggerEvent ) {
String text = null != ( text = getText() ) ? text : "";
this.putClientProperty(CLIENT_PROPERTY_DEAFULT_TEXT, text);
this.putClientProperty(CLIENT_PROPERTY_FIRE_ACTION_TIMES, String.valueOf(0));
final UIManager m = UIManager.getInstance();
setNativeCommandsText(m.localize("ok", "OK"), m.localize("cancel", "Cancel"));
this.addActionListener(nativeTriggerListener = getNativeTriggerActionListener());
} else {
this.putClientProperty(CLIENT_PROPERTY_DEAFULT_TEXT, null);
this.putClientProperty(CLIENT_PROPERTY_FIRE_ACTION_TIMES, null);
setNativeCommandsText(null, null);
if( null != nativeTriggerListener ) {
this.removeActionListener(nativeTriggerListener);
nativeTriggerListener = null;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}




ActionListener getNativeTriggerActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if( evt.getSource() instanceof TextArea ) {
final TextArea tar = (TextArea)evt.getSource();
final String textEntered = tar.getText().trim();
final String defaultText = (String)tar.getClientProperty(CLIENT_PROPERTY_DEAFULT_TEXT);
int fireActionTimes = Integer.parseInt((String)tar.getClientProperty(CLIENT_PROPERTY_FIRE_ACTION_TIMES));
++fireActionTimes;
int value = fireActionTimes % 2;

if( 0 == value ) {
fireActionTimes = 0;
if( textEntered.equals("") || textEntered.toUpperCase().equals(defaultText.toUpperCase())) {
tar.setText(defaultText);
}
triggeredNativeToLwuit(tar);
} else
//Switching to native edit screen
if( 0 < value ) {
if( textEntered.toUpperCase().equals(defaultText.toUpperCase()) ) {
tar.setText("");
}
triggeredLwuitToNative(tar);
}
}
}
};
}

关于java-me - LWUIT TextArea 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7384781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com