Introduction

This article explains how to use the Visual Debugger to locate and debug the code for visual elements in a GUI application. The debugger can be used in Java and javaFX GUI applications.
This article will help you with the following:

How to use a GUI snapshot?

  1. Select "File" -> ""New Project" from the main menu.
  2. Choose "Client Editor" in "Samples" -> "Java" category.
  3. Now click the "Next" button.
  4. Determine a location for your project.
  5. Finally, click the "Finish" button.
  6. After clicking the Finish button, the IDE launches the project and the project window opens with the project.
  7. To begin the debugging session click on the "Debug" main menu and select "Debug Main Project" in it (or you can right-click on the project node in the project window and debug).
  8. The debugging session begins, the IDE will launch the application and open the debugging window.
  9. At the time of debugging session select "Debug" -> "Take GUI Snapshot" from the main menu.
15.1.jpg

Visual Debugger: Implementation

The GUI Snapshot is a visual debugging tool that locates your source code for the GUI component. One can do the following on the snapshot:

Identifying the Source Code for Components

The GUI Snapshot description is explained in this section, you will become familiar with the use of a GUI snapshot to navigate to the line were a component is declared and initialized. A pop-up menu is used to invoke various commands when a component in a GUI snapshot is selected.
15.2.jpg
15.3.jpg
15.4.jpg
15.5.jpg

Examine Component Events

This explains the component events of the GUI snapshot.
  1. When we right-click on any of the components of the GUI snapshot and select "Show Listener" from the pop-up menu, the IDE opens the custom listener node.
15.6.jpg
  1. Right-click on the clienteditor.clientEditor$1 just below the custom listener node and select "Go to Component Source" in the popup menu. This opens the source code where the listener is defined.
  2. When an empty text field is selected, the items in the event window will change to show the listener of the selected component.
  3. To open the Select Listener Window, double-click on the Event node in the Event window.
  4. Choose the "java.awt.event.KeyListener" listener from the dialog box to make the text field listen to the keyboard events.
15.7.jpg