skip to main content
Programmer's documentation > Developing with the JViews Gantt SDK > Using JViews products in Eclipse RCP applications > The bridge between AWT/Swing and SWT
 
The bridge between AWT/Swing and SWT
The Standard Widget Toolkit (SWT) is the windowing toolkit of the Eclipse development environment and the Eclipse Rich Client Platform (RCP).
JViews components are Swing components and can be embedded in an SWT window, together with other SWT or JFace controls, in three ways. Each way provides a bridge between the AWT/Swing windowing system and the SWT windowing system.
*SWT_AWT. SWT_AWT is a low-level bridge.
*JViews IlvSwingControl. This class is part of JViews.
*Albireo SwingControl. This class comes from the Eclipse Albireo project (see http://wiki.eclipse.org/index.php/Albireo_Project).
Each of the three bridges has a number of advantages and disadvantages:
*SWT_AWT is low-level and has a number of bugs that require workarounds. It therefore requires a lot of coding to correctly implement features such as size management (because of different concepts of layout between SWT and AWT), look and feel, focus, cursors, and pop-up menus.
*JViews IlvSwingControl handles size management and fixes some of the focus, cursor, pop-up menu problems. It also provides an emulated bridge mode on Linux/gtk that reduces the flickering when the component is resized - at the expense of more flickering when parts of the component are redrawn.
*Albireo SwingControl also handles size management, and fixes more focus, cursor, pop-up menu problems than IlvSwingControl. It also fixes look and feel problems. However, it does not reduce the flickering.
Albireo SwingControl also supports input methods and newer JDKs better than IlvSwingControl. Though the examples supplied with JViews use IlvSwingControl, Albireo SwingControl is likely to become increasingly appropriate in future.
To create an SWT control from an IlvGanttChart object, you can use the following code with IlvSwingControl:
Composite parent = ...;
IlvHierarchyChart chart = new IlvGanttChart();
Control SWTchart = new IlvSwingControl(parent, SWT.NONE, chart);
Alternatively, you can use the following code with Albireo SwingControl:
Composite parent = ...;
Control SWTchart =
    new SwingControl(parent, SWT.NONE) {
      protected JComponent createSwingComponent() {
        return new IlvHierarchyChart();
      }
      public Composite getLayoutAncestor() {
        return parent;
      }
    };
NOTE >> The IlvSwingControl bridge is not supported on all platforms. It is only supported on Windows, UNIX® with X11 (Linux, Solaris™, AIX®, HP-UX®), and MacOS X 10.54 or later with JDK 1.5.
The IlvSwingControl bridge does not support arbitrary JComponents. Essentially, components that provide text editing are not supported. See IlvSwingControl for a precise description of the limitations.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.