第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何更正 TextField 中的希臘重音字符

如何更正 TextField 中的希臘重音字符

嗶嗶one 2023-06-21 15:06:22
我面臨的問題是當我有一個輸入(TextField、TextArea 等)并且我試圖插入一些包含重音字符的希臘單詞時。像“Γìτα”(貓)這樣的詞很好用。不幸的是,我無法輸入像“Τα?τ?”(塔希提島)這樣的詞。如果我嘗試復制并粘貼它或對其進行硬編碼,它工作正常,但是當我嘗試使用以下組合來寫這個詞時Shift + ';' +我應該產(chǎn)生'?',而不是我得到'¨ι'這是一個例子:import javafx.application.Application;import javafx.geometry.Insets;import javafx.geometry.Pos;import javafx.scene.Scene;import javafx.scene.control.TextField;import javafx.scene.layout.VBox;import javafx.stage.Stage;public class Example extends Application {    public static void main(String[] args) {        launch(args);    }    @Override    public void start(Stage stage) throws Exception {        VBox mainBox = new VBox(10);        mainBox.setPadding(new Insets(20));        mainBox.setAlignment(Pos.CENTER);        // Τα?τ? = Tahiti        TextField field1 = new TextField("Τα?τ?");        TextField field2 = new TextField();        mainBox.getChildren().add(field1);        mainBox.getChildren().add(field2);        field1.setStyle("-fx-font-size:24px");        field2.setStyle("-fx-font-size:24px");        stage.setScene(new Scene(mainBox));        stage.show();    }}下圖顯示了我自己輸入單詞時的結果安裝的 JRE:jre1.8.0_221安裝的JDK:jdk1.8.0_221為了將 IDE (Eclipse) 排除在問題的起因之外,我在 SceneBuilder 上僅使用一個 AnchorPane 和一個 TextField 測試了此行為,我在那里也遇到了同樣的問題。但為了便于討論,我在 Eclipse 中使用編輯器和所有設置來使用編碼 UTF-8。所以我想問:這是當前 JRE/JDK 的錯誤嗎?如果是,是否有我可以使用的眾所周知的解決方案,或者我應該只使用 Listener 來捕獲輸入并自己更正?編輯:正如 Sedrick 指出的那樣,我可以使用 alt + 0 2 3 9 的組合,但這將產(chǎn)生一種不同類型的字母,它與希臘字母相似但不相同??聪聢D。不幸的是,這不是我的客戶想要的行為,因為輸入它的正確方法(用希臘鍵盤)是使用:Shift + ';' + ι ,其中“ι”是英文字母“i”。
查看完整描述

2 回答

?
qq_遁去的一_1

TA貢獻1725條經(jīng)驗 獲得超8個贊

我可以重現(xiàn)這種行為。如果您在舞臺上添加一個,EventHandler您可以清楚地看到問題。

stage.addEventFilter(KeyEvent.KEY_TYPED,?ev?->?{
????System.out.println("Key?typed:?"?+?ev.getCharacter());
});

輸出:

Key?typed:?¨
Key?typed:?Ι
Key?typed:?¨
Key?typed:?ι

我們對此無能為力,只能提交錯誤報告。

我不知道您是否可以在KeyEvents發(fā)送這些鍵之前捕獲鍵入的鍵,但您可以在階段級別過濾它們。

stage.addEventFilter(KeyEvent.KEY_TYPED,?new?KeyTypedListener());

這不是很好,而是一種更“全球”的改變行為的方式。

public class KeyTypedListener implements EventHandler<KeyEvent> {


? ? private boolean disabled = false;

? ? private Map<String, String> charCombinations = new HashMap<>();

? ? private KeyEvent pendingEvent;


? ? public KeyTypedListener() {

? ? ? ? charCombinations.put("¨ι", "?");

? ? ? ? charCombinations.put("¨Ι", "?");

? ? }


? ? @Override

? ? public void handle(final KeyEvent event) {


? ? ? ? if (disabled || event.getCharacter() == null

? ? ? ? ? ? ? ? || event.getCharacter().length() != 1) {

? ? ? ? ? ? return;

? ? ? ? }


? ? ? ? final String typed = event.getCharacter();


? ? ? ? if (pendingEvent == null && isCombiCharacter(typed)) {

? ? ? ? ? ? pendingEvent = event.copyFor(event.getSource(), event.getTarget());

? ? ? ? ? ? event.consume();


? ? ? ? } else if (pendingEvent != null) {

? ? ? ? ? ? String combination =

? ? ? ? ? ? ? ? ? ? charCombinations.get(pendingEvent.getCharacter() + typed);


? ? ? ? ? ? if (combination == null) {

? ? ? ? ? ? ? ? disabled = true;

? ? ? ? ? ? ? ? fireEvent(pendingEvent);

? ? ? ? ? ? ? ? disabled = false;

? ? ? ? ? ? ? ? pendingEvent = null;

? ? ? ? ? ? } else {

? ? ? ? ? ? ? ? event.consume();

? ? ? ? ? ? ? ? pendingEvent = null;


? ? ? ? ? ? ? ? Platform.runLater(() -> {

? ? ? ? ? ? ? ? ? ? fireEventWithCharacter(event, combination);

? ? ? ? ? ? ? ? });

? ? ? ? ? ? }

? ? ? ? }

? ? }


? ? private boolean isCombiCharacter(final String character) {

? ? ? ? return "¨".equals(character);

? ? }


? ? private void fireEvent(final KeyEvent event) {

? ? ? ? Event.fireEvent(event.getTarget(), event);

? ? }


? ? private void fireEventWithCharacter(final KeyEvent event,

? ? ? ? ? ? final String character) {

? ? ? ? fireEvent(new KeyEvent(event.getSource(), event.getTarget(),

? ? ? ? ? ? ? ? event.getEventType(), character, "", KeyCode.UNDEFINED,

? ? ? ? ? ? ? ? event.isShiftDown(), event.isControlDown(), event.isAltDown(),

? ? ? ? ? ? ? ? event.isMetaDown()));

? ? }

}

當然你也可以創(chuàng)建一個新的EventDispatcher.


查看完整回答
反對 回復 2023-06-21
?
蠱毒傳說

TA貢獻1895條經(jīng)驗 獲得超3個贊

我認為這是希臘鍵盤的問題。我嘗試使用其他文本字段(Opera 搜索欄、Google 搜索欄等),但無法寫出這個字符。您只能使用 Alt+0239 組合來編寫此內(nèi)容。您可以嘗試使用“field2.setOnKeyPressed()”創(chuàng)建組合。



查看完整回答
反對 回復 2023-06-21
  • 2 回答
  • 0 關注
  • 172 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號