Home » desktop java » Page 4

Tag Archives: desktop java

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 »

MouseWheelListener example

With this tutorial we are going to show you how to use a MouseWheelListener in Java. This event listener is particularly useful when you want to add extra user friendly functionality in your application. For example, if you want the user to change the value of a specific item, you can allow him to do that using the wheel of ...

Read More »

MouseListener example

In this example we are going to see how you can use the MouseListener interface in Java, in order to monitor the mouse activity on your application. This is very useful when you wan to add extra functionality to you application and make it more agile, when you make it possible for the user to interact with it using the ...

Read More »

MenuListener example

With this example we shall show you how the MenuListener interface works in Java. Menu components are very usual in rich, Graphical applications and they contribute to a better user experience. So, a MenuListener component can be very useful when your application has many menu items and it’s important to monitor the user events and the user interactions with each ...

Read More »

A complete KeyListener Java Example

In this article,we will talk about java key listener and we will demonstrate a complete KeyListener Java example. 1. Introduction Java key listener is an interface used in Java Swing to monitor keyboard-related events that take place in your applications. This is particularly useful when you want to perform input validation on form fields or add shortcut functionality to your ...

Read More »

JRadioButton with ItemListener example

In this example we are going to see how to use JRadioButton bundled with an ItemListener. As you know, radio buttons a quite popular in Graphical Applications because they give flexibility to the end users, and it’s very natural to them to interact with radio buttons when you want to give specific values to choose from. In short, to use ...

Read More »