Defines an Action object with a default description string and default icon.
Questions tagged [abstract-action]
25 questions
6
votes
2 answers
Java: How to reference GUI components from an AbstractAction object?
It is often necessary to change the behaviour of other GUI objects depending on the state of another GUI object. E.g. when a button is pressed, a label shall change its name. However, when I use an AbstractAction object like JButton myButton = new…

user1812379
- 827
- 3
- 11
- 22
3
votes
1 answer
ActionListener vs AbstractAction
i am trying to learn more about event handling but everywhere i read about it, it's mainly about how to use it so something happens but not how it works.
So far i know about 2 ways to make something happen when a button is…

Flikk
- 520
- 3
- 10
3
votes
3 answers
How do I organize my Actions in Swing?
I am currently replacing my anonymous ActionListeners
new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
// ...
}
}
with class files representing actions:
public class xxxxxxxAction extends…

sdasdadas
- 23,917
- 20
- 63
- 148
3
votes
2 answers
Action and ActionMap - Explain me this behavior
I have an Action
SampleAction a = new SampleAction("foo", null);
Then I add it to a Button, and to an ActionMap
JButton b = new JButton(a);
b.getActionMap().put("bar", a);
b.getInputMap().put(KeyStroke.getKeyStroke("F1"), "bar");
I put a trace…

Fabricio
- 7,705
- 9
- 52
- 87
2
votes
2 answers
Changing the Background of a button after it is clicked (i.e. after Action performed)
I am trying to change the background of a JButton after it is clicked. Currently my buttons are located in a GridLayout (3x3) and look like this:
tiles.add(new JButton(new AbstractAction("") {
@Override
public void…

Matthew Kemnetz
- 845
- 1
- 15
- 28
2
votes
1 answer
Triggering Java GUI to update
There's probably a better question/answer for this but what I've been finding hasn't worked out and I have had trouble phrasing the question for google query. Basically I have a JFrame with several panels and components that pull their data from xml…

Mercutio
- 1,152
- 1
- 14
- 33
2
votes
0 answers
How to remove or disable a menu item from a JPopupMenu?
I have a JPopupMenu and I want to disable or remove, if possible, a menu item every time an action happens. So I tried this, and though the removeCommentAction object is added in the position 4 of the menu, the menu item in position 4 is not…

PetMarion
- 147
- 3
- 14
2
votes
1 answer
Change an AbstractAction name
I have a JMenuItem bounded to an Action that I can get using item.getAction(). The action name is set when constructing the Action, e.g. using anonymous new AbstractAction(String text, ...). The text field is set according to a ResourceBundle and…

remi
- 3,914
- 1
- 19
- 37
1
vote
0 answers
JButton won't show text
This class represents the button panel of a UI I have created, the second JButton named 'btnNext' doesn't display text however the first JButton does, why is this?
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import…

Emily
- 21
- 4
1
vote
1 answer
Does JavaFX has AbstractAction like swing has?
I'm building an app with javafx that need to have same buttons in toolbar and in menu. So it's easier to use abstract actions, like swing has. So my question is, does javaFx has something like that?

Filip Antic
- 19
- 1
- 1
1
vote
1 answer
Can paintComponent() be used in an AbstractAction class?
I am trying to make a program that creates a JPanel, and when the user presses W, A, S, and D, a cube that is drawn will navigate around in the window (by a certain amount every time a key is pressed), I have created the MoveCubeUp class, and I…

Mr.Binary
- 35
- 6
1
vote
1 answer
How to support ctrl + shift+ numpad keys using java.awt
I want to associate ctrl + shift + numpad 7 to an action map. Basically I'm trying to bind my actions to keyboard shortcuts and want the same behavior as of the number keys pressed from top or number keypressed from right numbers of keyboard.
I'm…

Bhavin
- 31
- 6
1
vote
2 answers
Calling a Java AbstractAction from a button/mouse release
In a simple calculator app, I use abstract actions to handle the buttons being clicked with the mouse and the respective number pad keys (with key bindings) being pressed. I wanted certain cosmetic changes to occur upon using the keyboard, such as…

KiloJKilo
- 465
- 1
- 6
- 16
1
vote
1 answer
Using boolean variable instead of ActionListner interface in swing
I have a small query please let me explain the scenario. I have a swing jframe in which i have a button named "start" which starts the timer in seconds so whenever i click on start it converts the the button itself to "reset" which should make the…

sumanth
- 15
- 7
1
vote
3 answers
Using Keybinding
I'm doing some very basic coding, just trying to learn the basic concepts behind keybinding. It all seems very straightforward but there's something wrong with my logic or structure that is keeping my code from executing the way I want it to.
Here…

Corey
- 152
- 1
- 3
- 11