Skip to content

Others

Get a list of keybindings for a JComponent

Section titled “Get a list of keybindings for a JComponent”
Get a list of keybindings for a JComponent

KeyBinding

We obtain the ActionMap and InputMap from the JComponent and create a list of KeyBindings.

Get the resource URL using ClassLoader

ClassLoader

Get the URL from ClassLoader using a relative path from the classpath.

Prevent duplicate launches of WebStart applications using SingleInstanceService.

Section titled “Prevent duplicate launches of WebStart applications using SingleInstanceService.”
Prevent duplicate launches of WebStart applications using SingleInstanceService.

SingleInstanceService

SingleInstanceService is used to prevent duplicate launches of WebStart applications and to retrieve arguments.

Preventing multiple instances of an application from running using ServerSockets.

Section titled “Preventing multiple instances of an application from running using ServerSockets.”
Preventing multiple instances of an application from running using ServerSockets.

SingleInstanceApplication

ServerSocket is used to lock the port and prevent multiple instances of the application from running.

Launch browser on desktop

Desktop

We will launch the browser using Desktop, which was introduced in JDK6.

Launch Browser

BrowserLauncher

Clicking the URL on the label will launch the browser.

Converting date displays using TimeZone

TimeZone

Use TimeZone or similar tools to convert the date display.

Implement EventListener to create custom events

Section titled “Implement EventListener to create custom events”
Implement EventListener to create custom events

EventListener

Create and use a new event object, event listener, and event source.

Obtain AWTEvent and monitor input events.

DispatchEvent

We obtain AWTEvents to monitor mouse and keyboard input events.

JRoot display status

ShowingDisplayableVisible

When the display state of a JComponent changes, we test the values ​​returned by its isDisplayable, isShowing, and isVisible methods.

Monitor DesktopProperty changes

DesktopProperty

Add a PropertyChangeListener to the Toolkit to monitor changes such as double-click speed.

Retrieve text and images from Clippage

SystemClipboard

This program retrieves text or image data from the clipboard and displays it in a JLabel.

Remember the position and size of the JFrame.

Section titled “Remember the position and size of the JFrame.”
Remember the position and size of the JFrame.

Preferences

Use Preferences to save the frame's position and size to the registry or elsewhere.

Use PersistenceService to remember the position and size of the JFrame.

Section titled “Use PersistenceService to remember the position and size of the JFrame.”
Use PersistenceService to remember the position and size of the JFrame.

PersistenceService

We obtain the PersistenceService from the ServiceManager and use it to save and retrieve the position and size of JFrames and other objects.

Clear the Mnemonic and reset the JButton to its initial state.

Section titled “Clear the Mnemonic and reset the JButton to its initial state.”
Clear the Mnemonic and reset the JButton to its initial state.

ClearMnemonic

This clears the Mnemonic set for the JButton, returning it to its initial state.

Display an image as the background of JRootPane

Section titled “Display an image as the background of JRootPane”
Display an image as the background of JRootPane

RootPaneBackground

An image is being displayed as the background for the JRootPane.

Resizing a JComponent with NimbusLookAndFeel

Section titled “Resizing a JComponent with NimbusLookAndFeel”
Resizing a JComponent with NimbusLookAndFeel

ComponentSizeVariant

If you are using NimbusLookAndFeel, you can change the display size of the component in the client properties settings.

Get the ScreenResolution from the Toolkit and change the font scaling used by the component.

Section titled “Get the ScreenResolution from the Toolkit and change the font scaling used by the component.”
Get the ScreenResolution from the Toolkit and change the font scaling used by the component.

ScreenResolution

This test will change the initial panel size, font size, line height, etc., based on the display resolution settings.

Use SecondaryLoop to run a separate event loop on the event dispatch thread.

Section titled “Use SecondaryLoop to run a separate event loop on the event dispatch thread.”
Use SecondaryLoop to run a separate event loop on the event dispatch thread.

SecondaryLoop

Use a SecondaryLoop to run the event loop in a separate thread without blocking the event dispatch thread.

The selection state of a JCheckBox is stored in a BigInteger, and the UndoManager is used to undo or redo the changes.

Section titled “The selection state of a JCheckBox is stored in a BigInteger, and the UndoManager is used to undo or redo the changes.”
The selection state of a JCheckBox is stored in a BigInteger, and the UndoManager is used to undo or redo the changes.

UndoRedoCheckBoxes

The selection states of multiple JCheckBoxes are stored in a BigInteger, and undo/redo operations are performed using UndoManager.

Recursively retrieve all child components of a container.

Section titled “Recursively retrieve all child components of a container.”
Recursively retrieve all child components of a container.

GetComponentsRecursively

We create a method that recursively retrieves all of the Container's child components and then retrieves the JTable placed in the JFileChooser.

Set Locale for JFileChooser

Locale

Set the Locale for JFileChooser to change the title and button text.

Test whether a key such as Shift is pressed when a JButton is clicked.

Section titled “Test whether a key such as Shift is pressed when a JButton is clicked.”
Test whether a key such as Shift is pressed when a JButton is clicked.

ActionEventModifiers

This tests whether a key such as Shift is pressed simultaneously when a JButton or JMenuItem is clicked.

Debugging JComponent rendering using DebugGraphics

Section titled “Debugging JComponent rendering using DebugGraphics”
Debugging JComponent rendering using DebugGraphics

DebugGraphics

Use DebugGraphics, a subclass of Graphics, to debug the drawing of a JComponent.