[英]Java JTextField cannot type
我已經查看了有關該主題的所有主題,但找不到解決問題的方法。
我有一個JPanels列表,其中一些包含JTextField。 帶有JButton和JCheckbox的其他面板可以完美地工作。
JTextField是可選的,但我不能鍵入它。 這是用於生成面板的代碼
setSize(new Dimension(450, 33));
JLabel lblPrefix = new JLabel(propertyToEdit.prefix);
lblPrefix.setBounds(12, 16, 56, 16);
add(lblPrefix);
JTextField stringInputField = new JTextField();
stringInputField.setEnabled(true);
stringInputField.setEditable(true);
stringInputField.setBounds(80, 13, 135, 22);
stringInputField.setColumns(10);
add(stringInputField);
這是Github上愚人節的代碼:)
找到了答案! 因為這個代碼
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher
在github上 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.