Skip Navigation

Development Workflow for Wrapping Swing Apps

  1. The following plug-in dependencies are required for Swing apps:

    • org.eclipse.albireo.core

    • com.sabre.edge.platform.core.common

    • If you are embedding your swing application in an editor, the com.sabre.edge.platform.core.editor dependency is also required. You need to add your application JAR file to the classpath of the plug-in.

  2. You can use the sample.jar file from the sample Swing plug-in.

  3. Wrap your Swing app in either an editor or a view.

  4. Add the required extension points and elements to create the editor or view. Add a command and handler, plus a menu contribution for your editor or view. Add a status line contribution, if it is required.

  5. Wrapping Swing apps requires you to adapt code. Extend the org.eclipse.albireo.core.SwingControl class to encapsulate the JComponent in your application. This class is required for all development. Implement the following abstract methods from SwingControl. These methods are required for all development.

    • createSwingComponent()

    • getLayoutAncestor()

Add your class into Composite in the same way that you add your class for any SWT component. To prevent lack of responsiveness in your application and to prevent deadlock, add your class into Composite in a separate thread.

  1. If you are programming interactions between Swing and SWT elements, modify your Swing code. Put the modified versions of your classes within the plug-in, in same package into which you placed them in your application JAR file. The package must be the same as the package in the JAR file.

Important

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 the following: javax.swing.SwingUtilities.invokeAndWait() and org.eclipse.swt.widgets.Display.syncExec()