key-bindings

Java KeyBindings: How does it work?

一个人想着一个人 提交于 2019-12-12 02:25:26
问题 I keep seeing that I should use Key Bindings instead of KeyListeners. So I found this page: Key Bindings. I read through it and tried to implement it. Action numPressed = new AbstractAction() { public void actionPerformed(ActionEvent e) { System.out.println("hi"); } }; this.getInputMap().put(KeyStroke.getKeyStroke("1"), "released"); this.getActionMap().put("released", numPressed); I decided to just see what would happen. The class this is in extends a JPanel. Earlier, I used this.setFocusable

Text Field and KeyBinding

别说谁变了你拦得住时间么 提交于 2019-12-11 17:36:40
问题 My textField is visible when textField.setBounds(27, 60, 150, 25) but I want it visible when textField.setBounds(27, 120, 150, 25) . How to put textField over JTable (hovering on top of JTable) and still visible? Here is my code: import java.awt.EventQueue; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.border.EmptyBorder; import javax.swing.table.DefaultTableModel; import

Foriegn keyboard support for Tkinter snaps

泪湿孤枕 提交于 2019-12-11 14:08:37
问题 I am currently developing a snap for learning foreign languages with Tkinter. However, it seems that typing in a different script doesn’t work in the snap, though it does when run normally. Is there a special interface I need? By the way, I think it's running TCL 8.6. My snapcraft.yaml is as follows: name: prosakart base: core18 version: '0.1.0' icon: icon.png summary: Application for language memorization. description: | ProSakart is a language-learning application, specifically for

Key combination of characters (non-Ctrl or Alt) in Java

前提是你 提交于 2019-12-11 13:55:17
问题 I'm doing a project that needs to detect if a certain key combination has been pressed. Any keys like Ctrl , Alt , A - Z and 0 - 9 can be used as key combination. I've searched some codes using KeyStroke.getKeyStroke but it seems like it does not allow combinations without a Ctrl , Shift , Alt , etc. My application needs to detect combinations even WITHOUT Ctrl or Alt e.g. just a combination of plain A + B + C . Is this can also be done with KeyStroke.getKeyStroke ? Replies are greatly

KeyBinding style

与世无争的帅哥 提交于 2019-12-11 12:13:53
问题 I use an ICommand class similar to RelayCommand and similar variations of that, but with extended properties that tend to go with a command. In addition to setting such properties as part of the Command setup, I can use them when binding. For example <UserControl.InputBindings> <KeyBinding Command="{Binding SaveCommand}" Key="{Binding SaveCommand.GestureKey}" Modifiers="{Binding SaveCommand.GestureModifier}" /> </UserControl.InputBindings> Now what I would like to do is have a style to take

Key Bindings in Command Prompt with Java?

我怕爱的太早我们不能终老 提交于 2019-12-11 10:37:59
问题 I have a java program running in a loop in command prompt (I open command prompt and execute a java command). I wanted to setup some key binding (like ctrl+q) so that I could exit the java program while it is running (the program is running through a while loop). Is there anyway to do this? I was trying to use key mappings but wasn't getting it to work. Do custom key mappings not work in command prompt? 回答1: As keith.layne points out, this is OS specific. For console programs, the OS provides

Deactivate selection by letter in JList

点点圈 提交于 2019-12-11 09:47:19
问题 I've got a JList list and the following code line: list.getInputMap().put(KeyStroke.getKeyStroke('d'), "action"); So when my list is in focus and I press the d key on my keyboard an action should be performed. That action takes into account which item of my JList is currently selected. The problem is that whenever there is an item in my list with first letter 'd' my selection will jump to that entry first and then do the action (applied to the wrong item). So my question is: How do I disable

Combo Box pop up and select using keyboard shortcuts

给你一囗甜甜゛ 提交于 2019-12-11 09:19:26
问题 public static void comboBoxActionPerform(JComboBox comboBox) { String ACTION_KEY = "myAction"; Action actionListener = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { JComboBox source = (JComboBox) actionEvent.getSource(); source.showPopup(); source.setFocusable(true); } }; KeyStroke ctrlT = KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_MASK); InputMap inputMap = comboBox.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(ctrlT, ACTION

Eclipse Editor plug-in key binding not shown in menu for command

假装没事ソ 提交于 2019-12-11 08:20:08
问题 I have a key binding that triggers a command in my custom Eclipse editor plug-in: <key commandId="my.plugin.ui.MyCommand" contextId="my.plugin.ui.mycontext" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" sequence="M1+M2+O"> </key> I am using a newly defined context mycontext to be able to overwrite the already existing key binding for organizing imports. mycontext is a child context of org.eclipse.ui.contexts.window . When creating a menu entry for this command, the keyboard

How to prevent the browser to override my keyBindings of ace editor?

最后都变了- 提交于 2019-12-11 08:01:52
问题 This question came up after i implemented the ace editor... here is the link for that: Ace editor, how to remove all keyBindings but one? I have the ace editor, and thx to the for loop: for (key in editor.keyBinding.$defaultHandler.commandKeyBinding) { if (key !== "ctrl-d") delete editor.keyBinding.$defaultHandler.commandKeyBinding[key]; } I have my own keyBindings, and the ace editor has its own, witch i deleted, all but one, and that one is the CTRL+D to remove a line... but, my browser has