Key « JFrame « Java Swing Q&A





1. Java KeyListener for JFrame is being unresponsive?    stackoverflow.com

I'm trying to implement a KeyListener into my JFrame. On the constructor, I'm using this code:

System.out.println("test");
addKeyListener(new KeyListener() {
    public void keyPressed(KeyEvent e) { System.out.println( "tester"); }

   ...

2. Disable default ALT key action in JFrame under Windows    stackoverflow.com

I would like to let my JFrame under Windows not act upon an ALT key press. To clarify, when you execute the following snippet of code:

import javax.swing.*;

public class FrameTest {
  ...

3. Swing: Setting a function key (F2) as an accelerator    stackoverflow.com

I have a menu item, "rename", for which F2 is set as an accelerator. Indeed when the menu is displayed there a little "F2" indication next to "rename". Sadly, this does not ...

4. Is it Possible to show a previously hidden JFrame using a keylistener    stackoverflow.com

here is my code, i basically just did a tester for the most common listeners, which i might later use in future projects, the main problem is in the keylistener at ...

5. How to add a keylistener to JFrame Subclass    stackoverflow.com

I implemented all of the necessary methods and added the "implements KeyListener" and added the addKeyListener and setFocus(true) but I get no keyresponses. The JFrame includes a canvas class that I ...

6. Problem with KeyListener and jframe    stackoverflow.com

I've got problem with JFrame and KeyListerner in Tetris game. I've got two frames - one with Start Button and second with Board. In the second frame I want to control ...

7. capture key press within frame    stackoverflow.com

This seems like a simple behavior, but I'm having difficulty making it happen. I'm working on software which graphs data. I want to redraw the graph when the user ...

8. Close window on pressing of certain key    stackoverflow.com

I just started using java and am not very good, so if you could help me that would be awesome! I'm making a Swing application and want to close it only ...

9. Java - KeyListener, keyPressed versus keyTyped    stackoverflow.com

I have a JFrame (well, a class which extends JFrame) and I want to do an action when I press the F5 key. So, I made the class implement KeyListener. And ...





10. How to make "Enter" Key Behave like Submit on a JFrame    stackoverflow.com

I'm Building a Client/Server application. and I want to to make it easy for the user at the Authentication Frame. I want to know how to make enter-key submits the login and password ...

11. key name for JFrame icone (Urgent)    coderanch.com

12. Register Key to a JFrame    coderanch.com

14. how to close window with return key    coderanch.com

hi everyone i'm trying to close a window with a close-button when hitting the return key of my keyboard. but when hitting the key the only thing that happens is that the button gets selected (i've set it as default button). i've put a keylistener to my close button. does anyone know how to do that? regards

15. Key presses one by one in JAVA Swing (only in Frame)    coderanch.com

I think that would be the case when a certain key is kept pressed down, but what is the case for example: I want to press a key like d for leg spin and the sound would start representing that of the bowler running and after 3 seconds I would take the direction from the direction key. But when the first ...

16. How to use Multiple Keys in a JFrame    coderanch.com

public class MyFrame extends JFrame { JPanel pane = new JPanel(); public MyFrame() { System.out.println("test"); addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { System.out.println("tester"); //TRYING TO ADD CNTR+F BUTTON SCENARIO HERE } public void keyReleased(KeyEvent e) { System.out.println("2test2"); } public void keyTyped(KeyEvent e) { System.out.println("3test3"); } }); this.setFocusable(true); JTable table = new JTable(); JScrollPane scroll = new JScrollPane(table); pane.add(scroll); getContentPane().add(pane); } ...





17. Accelerator key for JToolBar    coderanch.com

18. using JFrame with KeyListener Interface and using paint method    coderanch.com

import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import javax.swing.JFrame; import java.awt.Toolkit; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.geom.AffineTransform; import java.net.URL; import java.util.*; public class DrawImage extends JFrame implements KeyListener{ private Image image; private Graphics2D g2d; public static void main(String[] args) { JFrame jf = new DrawImage(); jf.setFocusable(true); jf.setVisible(true); } DrawImage() { super("DrawImage"); setSize(600,500); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Toolkit tk = Toolkit.getDefaultToolkit(); image = ...

19. how to close a JFrame When Pressing Esc Key?    forums.oracle.com

20. Get KeyListener back to JFrame    forums.oracle.com

Hi, the abstract problem I am having, seems to be a little bit tricky: A JFrame is given implementing the KeyListener interface and owning a JPanel instance which is set to setVisible(false) at the beginning. At this time the KeyListener works. After a certain time the panel appears offering a button that makes the panel disappear again. Now the problem is, ...