Home » desktop java » Page 10

Tag Archives: desktop java

Handle focus changes example

In this tutorial we are going to see how to handle focus changed in a Java Desktop Application. You might find this particularly useful if you have an application that contains many objects and you want to monitor the focus changes over these objects, if you always want to know the object that the user interacts with. You can use ...

Read More »

Handle action events example

In this tutorial we are going to see how ActionListener works in Java. This is one of the most important components you have to work with when you’re developing a GUI Application. The ActionListener is able to monitor a number of important events that occur in GUI Apps. In short, all you have to do to work with an ActionListener in Java is: Create an ActionListener instance. Override ...

Read More »

Determine click count example

With this tutorial we are going to see how can you determine the number of clicks that a user performed over an object in a Java Desktop application. This is very useful when you want the user to have rich interaction with your application using his mouse. You can also add extra functionality according to how many clicks the user did ...

Read More »

Drag and Drop example

In this tutorial we are going to see how to build a simple application that performs drag and drop operations in a Java Desktop Application. As you know the drag and drop operation is very important in an Application that has to deal with graphical objects. In short, in order to add drag and drop functionality to your application you ...

Read More »

Getting and setting text on the system clipboard

With this example we are going to see how to get and set the text on the system clipboard. This is a very common feature that we all use every day when working on a computer. The most common use of this is when we perform text copy/paste operations. Using this example you can embed this operations in you own ...

Read More »

Focus listener example

This is an example that discusses how to use FocusListener in Java. This is a very handy feature when you have several components and you want to monitor and handle the event when on of them gains or looses focus. In short, all you have to do in order to work with a FocusListener is: Create a new FocusListener Override the methods that correspond to ...

Read More »

Setting the initial focus component in a Window

With this example we shall show you how to set the component that gets the focus when your application starts up. This is very useful when you have many graphical objects firing up at the start up of your application. Let’s see the code snippet that follows and it should be pretty clear:           package com.javacodegeeks.snippets.desktop; ...

Read More »

Prevent an Application Window or Component from gaining focus

With example we are going to see how to prevent a window and a graphical object from gaining focus in a Java Desktop Application. This is very simple, as the only thing you have to do is: Call setFocusable(false) to prevent a component from gaining focus. Call setFocusableWindowState(false) to prevent a window from gaining focus. Call getCurrentKeyboardFocusManager().clearGlobalFocusOwner() to remove the ...

Read More »

Hide Frame when closed example

With this example we are going to see how to hide a closed frame. To do that all you have to do is: Create a new WindowAdapter instance. Override windowClosing method. Now every time a the window closes this method will fire up. Use Frame.setVisible(false) to hide the frame you want.       Let’s see the code: package com.javacodegeeks.snippets.desktop; ...

Read More »

Exit application when Frame is closed example

With this tutorial we shall show you how to exit from your application when a frame is closed. This is a very common use for most GUI applications. This is very easy to do, all you have to do is: Create a new WindowAdapter instance. Override windowClosing method to customize the handling of that specific event. Now every time a ...

Read More »