state « Event « Java Swing Q&A





1. Best approach for dual-state Action    stackoverflow.com

I have recently implemented an Action that toggles the enabled status of a business function. Whenever the user invokes the action I set a boolean flag: "willEnable" to determine whether ...

2. Java swing: how to know the state of the mouse from outside the component receiving the event?    stackoverflow.com

I want to know the state of my mouse buttons (pressed or not), from outside the target component. I don't want to use a glasspane to intercept events. The MouseInfo class can give ...

3. Triggering events in Java when an object's state changes    stackoverflow.com

I have an object in Java whose state changes over the course of time. When one of the fields in the object reaches a certain value, I want an external event ...

4. How to fire a mouseOver state?    stackoverflow.com

Is there a way I can fire a mouseOver event so that when I hover over a button, other button(s) gets hovered too (e.g. change the icon) ? I work in ...

5. Item State Change event is not noted.    coderanch.com

6. Getting SHIFT key state    coderanch.com

7. AbstractAction toggle state    coderanch.com

8. AbstractAction with toggle state    coderanch.com

import java.awt.*; import java.awt.event.*; import javax.swing.*; final class Test { private static final Image lightning = Toolkit.getDefaultToolkit().createImage( Test.class.getResource("/img/lightning.png")); private final Action toggle = new AbstractAction("Toggle", new ImageIcon(lightning)) { { putValue(Action.SELECTED_KEY, false); } @Override public void actionPerformed(ActionEvent e) { boolean selected = (boolean) getValue(Action.SELECTED_KEY); System.out.println(selected); } }; public Test() { JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menubar = new JMenuBar(); frame.setJMenuBar(menubar); ...