Key « Focus « Java Swing Q&A





1. How to avoid that pressing the ALT key takes away the focus from my GUI    stackoverflow.com

I'm developing a java app with swing in Windows. The problem is: after pressing (and releasing) the ALT key, the next key press has no effect (there won't be a keyPressed event ...

2. Handle key presses using draw2d and swt    stackoverflow.com

Every org.eclipse.draw2d.Figure class has addKeyListener() method. But when key presses not every Figure handle it. What kind of figure handles key-events? Thanks.

3. transfering focus with enter key    coderanch.com

I am trying to allow the user to press enter and have the cursor move to the next textfield. I have it working for the first textfield, it will move it to the next textfield but I don't know how to get it to move to the next textfield from there. Does that make since? I need some advice on how ...

4. Setting Focus on Enter key pressed    coderanch.com

5. Key Binding not working when child component has focus    coderanch.com

final JFrame frame = new JFrame(); final MyJpanel panel = new MyJpanel(frame); panel.setFocusable(true); panel.textField.requestFocusInWindow(); panel.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"), "pressed"); panel.getActionMap().put("pressed", new AbstractAction() { public void actionPerformed(ActionEvent e) { //do nothing System.out.println("Hello"); frame.setVisible(false); frame.dispose(); System.gc(); System.exit(-1); } }); frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); frame.getContentPane().add(passcodePrompt); frame.setAlwaysOnTop(true); frame.setLocation(400, 300); frame.setUndecorated(true); frame.setResizable(true); // frame.addWindowFocusListener( frame.setFocusTraversalKeysEnabled(true); frame.setFocusable(true); frame.pack(); JDialog dialog = new JDialog(frame, true); dialog.setUndecorated(true); dialog.setContentPane(panel); dialog.setPreferredSize(panel.getPreferredSize()); dialog.setSize(panel.getSize()); dialog.setLocation(400, 300); dialog.addWindowFocusListener(new WindowAdapter() { ...

7. key press triggering something when program isn't in focus    java-forums.org

i'm writing a bot, and since the task i'm making it do is going to move the mouse frequently, it would be difficult for the user to try and stop it by putting the program in focus and pressing a button. so i think the next smartest thing is to stop it when a combination of keys are pressed. However, there's ...

8. Focus traversal keys not responding    java-forums.org

Hi, The focus traversal keys like tab, shift+tab, ctrl+tab etc. have stopped responding on my JInternalFrame ever since I was fiddling with focus-subsystem related properties in the Properties window of this component. I have since changed the focus-related properties randomly many times in the hope that the problem will be sorted out, but to no avail. Could someone tell me what ...