Detect « Event « Java Swing Q&A





1. Detecting keyboard direction keys using keyPressed    stackoverflow.com

G'day all, After learning on here that the Java console doesn't support keyboard input a great deal, I switched to Swing and AWT. My problem now is how to detect when ...

2. Java AbstractAction sometimes not detecting escape key - bizarre behaviour    stackoverflow.com

In a master/detail view I have a series of text fields (and one or two other controls) that all pertain to the detail of the currently selected item. They all share ...

3. Detecting where a change event came from    stackoverflow.com

I have a bunch of JTextComponents that fire update events to a common model. The model then fires out change events to the other components so they can all be ...

4. Java swing: how to detect when the mouse is at rest    stackoverflow.com

I wrote some code that has a jpanel with a mouse listener and mouse motion listener, and it is working fine, but I run want some animations when the mouse is ...

5. Swing: detect mouse move on generalpath    stackoverflow.com

I'm drawing some splines using GeneralPath as follow:

GeneralPath path = new GeneralPath();
path.moveTo(x0, y0);
path.curveTo(x0 + 100, y0, x1 - 100, y1, x1, y1);
((Graphics2D) g).draw(path);
Basically, this draws a spline that looks like a ...

6. Detecting Shift modifiers on MouseEvent generated from click in swing    stackoverflow.com

I'm handling some MouseEvent in a GUI application using Java Swing. Since now i was analyzing mouse events inside mousePressed method, only to determine if a left or right click happened. My code ...

7. how to detect double clicks in MouseInput in Java swing?    stackoverflow.com

How can I catch when user double clicks on the component?

 window.getComponent().addMouseListener(new MouseInputAdapter(){
            public void mouseClicked(final java.awt.event.MouseEvent evt) {
  ...

8. Detecting which way mouse is scrolled    stackoverflow.com

There is only one method in the MouseWheelListener interface. I need to do different things depending on whether the mouse is scrolled up or down. How to achieve such a thing? ...

9. Java detect long mouse press    stackoverflow.com

Is there any way to capture an event if a user press on JList component for more than 3 seconds? The difficult part i find is the event needs to be ...





10. Swing : detecting onKeyPressed    stackoverflow.com

I'm trying to do a very simple thing : trigger an action when the user presses on a key of the keyboard the keys I would like to map are :

  • key ...

11. How to detect a click event in an Image class in java?    stackoverflow.com

I'm practicing to learn java by creating a simple game.In my simple game,I want to use the awt image class and I want to click the image class and it will ...

12. How can a KeyListener detect key combinations (e.g., ALT + 1 + 1)    stackoverflow.com

How can I let my custom KeyListener listen for combinations of ALT (or CTRL for that matter) + more than one other key? Assume I have 11 different actions I want the ...

13. how to detect the click of the mouse?    coderanch.com

14. How to detect right click?    coderanch.com

15. How to detect Successive key type events??    coderanch.com

Hi, I have a situation in which i need to detect Successive key type events. What i mean is if some one types "Saj" in a stretch, there would be little delay(say 10 milliseconds) between the type of 'S', and 'a' and 'j'. The other case is someone would first type 'S', then after some(say some 1 or 2 seconds) time ...

16. Detecting double-click events    coderanch.com





17. Detecting GUI event    coderanch.com

19. Mouse-Move-Detection    coderanch.com

Hi again! This has been my first solution for this problem. But there are still other widgets on my canvas which disable my MouseMove-Detection while dragging the button across another widget. What I've done is to disable directly the button while dragging it around, for this reason it his half-transparent. That doesn't bother, but now when I have to disable all ...

20. Detecting global mouse click    coderanch.com

Hi, I have an application which has several transparent components, and I want to detect a mouse click on them. Unfortunately, transparent components don't seem to register any mouse events. So is there any way of detecting a mouse click just on a kind of global basis? Once a click is detected, I can easily tell whether the mouse is inside ...

21. Detect AltGr key?    coderanch.com

Hi! Is it possible to detect the AltGr (right alt) key from Java? Running this program with JRE 1.6.0_15 on Windows XP gives two codes when AltGr is pressed: CTRL and ALT KeyEvent.isAltGraphDown() always returns false. The program is http://java.sun.com/docs/books/tutorialJWS/uiswing/events/ex6/KeyEventDemo.jnlp Note: US keyboard layout generates ALT code when the right alt is pressed. Switch the OS keyboard layout setting to German ...

22. Detecting mouseEntered event in JComponent    java-forums.org

I'm having one of those days. My application has a JComponent that serves as a paintable canvas, onto which other components (PaintedCircle) are drawn. I want the PaintedCircle objects to detect mouseEntered events and report them but I can't seem to make that happen. I get all of the events from the canvas JComponent but none from the PaintedCircle objects. Thanks ...

23. Detect keypresses without consol or GUI    java-forums.org

I want to make a bot for someone that will monitor a chatroom and bans any newcommers. All of the bots that I've made before have been fine having a limited number of loops -- if they got out of hand, then I'd just let them run their course until the loop expired. This one I want to run for an ...