Home » Desktop Java » awt » event

event

Window closing event handling

In this example we are going to see how to handle window closing events. This is a very basic event handling when you are working on a UI Application. Basically all you have to do to handle window closing events is: Create a simple JFrame window Use addWindowListener to add a window listener to the JFrame Override windowClosing method of ...

Read More »

VetoableChangeListener example

With this example you are going to learn about a very important event monitoring component, the VetoableChangeListener. The VetoableChangeListener is , in many ways, similar to the PropertyChangeListener class. The main difference is that PropertyChangeListener is applied to bound properties. On the other hand the VetoableChangeListener is applied to constraint properties. A bound property is just as simple as a property. A ...

Read More »

WindowListener demo

In this tutorial we will see how to use the WindowListener. This is particularly useful when you are working with a window application and you want to monitor the state of each window. With the WindowListener you can monitor a number of events. The opening or the closing of a window for instance. So, when a window opens or closes, ...

Read More »

Display all events occurring in a window

In this example we shall show you how to display all events occurring in a windows. This is very useful when you want to have full control o events that occur in a Java applications that has many windows to handle. It is a very simple ways to manage the activity on your windows. To display all the events that ...

Read More »

Multicast event example

In this tutorial we are going to see how to manage multicast events. Multicast events are quite useful when you have to work with many windows in your application and you just want to perform the same action or a group of actions in a number of windows in your application at the same time. For example, if the user ...

Read More »

Multiple listeners example

In this example we are going to talk about how to work with multiple listeners in Java. This is particularly useful when you want to register more than one listeners in a single component, a button for instance. All you have to do to work with multiple listeners is: Create a class that extends JFrame and implements ActionListener. Create an ...

Read More »

Keymap and KeyStroke example

With this example we are going to see how to use Keymap and KeyStroke classes in a Java. These classes are useful when you want to bind a certain key stroke with the default button of the window. In order to work with Keymap and KeyStroke: Use KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false) method to get the “Enter” key stroke. Use Keymap.removeKeyStrokeBinding to ...

Read More »

Change Event behavior dynamically

In this example we are going to see how to change the behavior of an event dynamically in your Java program. It is very simple to add this kind of functionality in your application. All you have to do is: Create some classes that implement the ActionListener interface. Bundle these ActionListener with a specific button or component using addActionListener method. ...

Read More »

Items with the same ActionListener

With this tutorial we are going to show you how to create several items with the same ActionListener. This is very useful when you want a number of components to behave in the same way under the occurrence of certain events. It’s very easy to add this kind of functionality in your Application. You simply: Create the items you want ...

Read More »

PopupMenuListener example

With this tutorial we shall show you how use PopupMenuListener interface in Java. You can use this listener to monitor your popup menus by overriding certain methods that fire up when a specific event concerning the popup menu occurs. All you have to do in order to use a PopupMenuListener is: Create an new JComboBox Create a new PopupMenuListner Override ...

Read More »