Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » About the SWT_AWT bridge focus bugs
About the SWT_AWT bridge focus bugs [message #1805855] Thu, 25 April 2019 14:32 Go to next message
Djak Mising name is currently offline Djak Mising nameFriend
Messages: 15
Registered: November 2010
Junior Member
I'm looking for help about some SWT_AWT problems that are present in the platform for many years. There are some focus bugs that lead to various dysfunctions in SWT and RCP mechanism when embedding some AWT/Swing components in SWT composites. The behaviors are different on Linux, Windows and Mac and the dysfunctions are very hard to track.

Here is a list of related bugs:
and an issue at Oracle site:

None of workarounds created or found works for all the issues we have found in our application.

It seems the rewrite of the JRE AWT part in Java 1.7 has increased the number of dysfunctions.

Could anyone redirect me if I'm not at the right place ?

Actually I'm looking for any news and advises about this problem.

My main analysis is:
- the AWT Window activation/deactivation and focus gained/focus lost behaviors are different on Linux, Windows and OS X
- a bug in JRE seems to make difficult (impossible?) to resolve the issue in SWT
- the focus bug leads to various SWT/RCP bugs, for example: parts not activated, menu contributions not shown even if part is activated, SWT Widget never lose focus, AWT Frame never loses focus, Key event fully grabbed by AWT leading to some SWT Widget not responding
- maybe the problem is not only related to focus but also to events delegation
- the problems are still there in RCP2019-03 / SWT 3.110.0 + JRE 1.7, 1.8, or 1.10

Actually I'm looking for any information about this issue, my request for help is for example:

- do we know if the problems can be resolve outside the JRE? I meant in SWT
- is there a workaround that has been "proved" to work anywhere?
- should I continue to create issues with new discovered bugs at or is it useless (eg. the problem is in the JRE)
- do you think we need to stop to use the SWT AWT bridge?
- can we help for something?
- could the developers communicate about these problems?

Any tips will be very appreciated.
Thank you very much.

Here is, for example, a minimal sample for Linux that shows some various problems:
- once the AWT TextField has gained the focus it grabs all key events, impossible to type keys in the SWT Text widget
- the SWT Text Widget never loses the focus
- the AWT Frame never lose the focus

import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.TextField;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class SWTAWTFocusBugsSnippet {

	public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		Composite composite = new Composite(shell, SWT.EMBEDDED);
		Frame frame = SWT_AWT.new_Frame(composite);
		Panel panel = new Panel(new BorderLayout());
		panel.add(new TextField());
		Text text = new Text(shell, SWT.BORDER);

		while(!shell.isDisposed()) {
			if (!display.readAndDispatch()) {

[Updated on: Thu, 25 April 2019 14:36]

Report message to a moderator

Re: About the SWT_AWT bridge focus bugs [message #1807690 is a reply to message #1805855] Thu, 06 June 2019 09:09 Go to previous message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 42
Registered: April 2012
I initiated the bug report on Java, after seeing multiple frameworks struggle, see also Bug 377104.

What seemed to work back then (for windows), was creating a Composite that identified itself as being Internet Explorer. Then the JRE does emit an activation event. However, this identification is internal API of SWT, so its a bit tricky to build it. I have to look around if I got the code still somewhere.

There has been the Albireo Project, that tried to address many of these issues too.
Some time ago I was thinking about creating an SwingCanvas in SWT (based on Canvas, not on Composite) to address many of theses issues and have a better out of the box experience.

The guys of Java-in .NET might have also found workaround/fixes for these issues.

Previous Topic:Eclipse RCP 3.x to 4.8 migration
Next Topic:Can strings in introContent be externalized?
Goto Forum:

Current Time: Sun Aug 18 11:05:11 GMT 2019

Powered by FUDForum. Page generated in 0.01978 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top