Skip Navigation

Modifying Swing Code to Interact with UI Elements

If you want to add interaction between your Swing app and other UI or workbench elements, complete this step.

  1. Modify your Swing code. Provide the modified versions of your classes within the plug-in, in the same package into which you placed them in your application JAR file. This package must be the same as the package in the JAR file. In the sample Swing app, this package is com.sabre.redapp.example.swing. The modified code is placed in the src folder.

        Sabre Red 360 loads the modified version of the class before it searches for the class in the JAR file; consequently, the plug-in uses the modified class.

        In the sample Swing app, the modified class is ButtonActionListener , which is in the file in the swing plug-in and the sample Swing app.

        This code replaces the same listener class that is defined in sample.jar. The listener class is from the Swing app.


If you are writing code to implement interaction between Swing and SWT, use the following methods:

  • javax.swing.SwingUtilities.invokeLater()

  • org.eclipse.swt.widgets.Display.asyncExec()

Using these methods avoids deadlocks and increases the responsiveness of the whole application. These methods replace javax.swing.SwingUtilities.invokeAndWait() and org.eclipse.swt.widgets.Display.syncExec().