Home » Desktop Java » awt » event (page 4)

event

A simple application to Load – Save – Edit a file

This is an example on how to create a simple GUI application that Loads, Edits and Saves a file in Java. You might find it useful if you wish to add such a functionality built into your app. For example if you have an application that handles Files, and you want to add a “Quick Edit” option. Basically, to create ...

Read More »

List actions of some Components

With this example we shall show you how to create a simple application that lists the actions of some Components you can use in your Java Desktop Application. You might find it particularly useful if you want to to add a “Help” functionality in your applications. In short, all you have to do is : Create a String array with ...

Read More »

Focus change example

In this example we are going to see how to change focus in a Java Application. All you have to do is: Create a new ActionListener. Override the actionPerformed method. When this method fires up use the transferFocus method to transfer the focus to a specific component. Create a class that extends MouseAdapter. Override the mouseEntered method When this method ...

Read More »

A simple Timer example

With this tutorial we are going to see how to use the Timer component in Java. The Timer component is very useful when you want to schedule some tasks in your application. In our case we are going to use this component to fire up an ActionListener that prints the value of a counter. In short, to use the Timer ...

Read More »

PropertyChangeListener example

In this tutorial we are going to see how to use PropertyChangeListener in Java. This is very important when you are working with many components and you want to have full control over their properties. Another use case of this Listener might be when you want to customize the behavior of your program according to the changes of certain properties ...

Read More »

Change active keystrokes

With this tutorial we shall show you how to change active keystrokes in a Java application. You might find this useful when you are developing an application that has rich and intense keyboard activity and you want to customize it to make it very flexible for each user dynamically to use his own keystrokes. In short, to change active keystrokes ...

Read More »

AncestorListener example

In this example we are going to see how AncestorListener can be paired with a timer in Java. This is very useful when you add or remove components to your Java Application and you want to monitor the relationship changes that follow these actions. Basically, all you have to do in order to work with AncestorListener  in Java is: Create a new AncestorListener instance. Override ...

Read More »

A simple ChangeListener example

In this example we are going to see how to use the ChangeListener interface in Java. This is very useful when you want to monitor generic changes in your application. In short, to use a simple ChangeListener one should follow these steps: Create a new ChangeListener instance. Override the stateChanged method to customize the handling of specific events. Use specific ...

Read More »

A simple text menu using TextAction example

With this tutorial we are going to show you how to create an application with a simple text menu that uses TextAction in Java. This will be particularly useful when you want to create a simple and fast menu for your GUI Application. In order to work with TextAction in Java: Create a JTextArea component. Use the getActions() methods of ...

Read More »

CheckBox Listener example

In this tutorial we are going to see how you can use an ActionListener, a ChangeListener and an ItemListener with the JCheckBox component to construct a CheckBox listener. This is very useful because it gives a generic way to construct you own custom listeners based on the build in ones, in your own components. Basically all you have to do ...

Read More »