Questions tagged [actionevent]

In Java, an action event is a semantic event which indicates occurrence of an action generated by a component like a button. This action event then passes to its ActionListener object, which is done by calling addActionListener method of the component.

When a user performs an action event like a click event on a button in any java based application this click is transformed to an ActionEvent that is generated and received by its ActionListener object. ActionListener is a java interface which works as a receiver of action events.

The class that is interested in processing an action event should necessarily implement this interface, and the object created with that class is registered with a component, using the component's addActionListener method. When the action event occurs, that object's actionPerformed method is invoked whenever an action occurs.

The class ActionEvent is a public class which extends AWTEvent class of java. The action event like clicking of a button can also be performed using keyboard by pressing the space bar.

Class ActionEvent provides 3 predefined constructors:

  • ActionEvent(Object source, int id, String command) Constructs an ActionEvent object.

  • ActionEvent(Object source, int id, String command, int modifiers) Constructs an ActionEvent object with modifier keys.

  • ActionEvent(Object source, int id, String command, long when, int modifiers) Constructs an ActionEvent object with the specified modifier keys and timestamp.

Usage: The tag actionevent can be used for programming problems related to GUI applications and event handling based problems in java. This tag should not be used for problems related to event handling in javascript and other languages.

Official documentation for class ActionEvent can be found at http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionEvent.html

306 questions
-2
votes
1 answer

error in quiz game using swings

I am having some problem in my quiz game. i am using netbeans. in my game i have two classes 1st is my driver class ie Quiz and second is non driver class ie RadioQuestion. i am posting my code for both the classes. i am having two errors in my…
-2
votes
2 answers

How does one determine if an EventObject is a MouseEvent an ActionEvent or something else?

How does one determine if an EventObject is a MouseEvent an ActionEvent or something else? Is there a simple way to check the type of an EventObject?
user1585643
  • 211
  • 1
  • 2
  • 9
-2
votes
2 answers

How to change what a button does?

I am currently creating a game in Java using Swing. I have a button, and once it does one thing, I want it's action to change. I have tried if statements, if-else statements, while loops, and various other things, and I can't get it to work. Anyone…
-3
votes
2 answers

Changing label text when button is clicked

I am trying to create a swing app that is a quiz. I need the jLabel to change on a button click but when I click the button, the app locks up. Can someone point me in the right direction? My button click code is below: private void…
pls3399
  • 53
  • 6
-3
votes
1 answer

Java XOR encrypting binary files

I have got an app to encrypting text files using XOR. Now I need to modify it to code binary files (such as jpegs) using another binary files (as a key). How can I do that? Does it has something in common with binary offset? I need it for learning…
user3235376
  • 87
  • 1
  • 2
  • 10
-3
votes
2 answers

Java Hangman GUI not properly displaying

I'm having a couple of different problems with my code, most of them are GUI based problems but i do have one actionevent problem. I will post my code in sections first then I will point out what the issue is specifically with each section. *note…
Richard Paulicelli
  • 129
  • 3
  • 6
  • 23
1 2 3
20
21