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: 16
Registered: November 2010
Junior Member
Hi,
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: https://bugs.eclipse.org/bugs/buglist.cgi?quicksearch=AWT%20SWT%20Focus&list_id=18659835
and an issue at Oracle site: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8203855

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 https://bugs.eclipse.org 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());
		frame.add(panel);
		panel.add(new TextField());
		
		Text text = new Text(shell, SWT.BORDER);
		
		shell.setSize(200,70);
		shell.open();

		while(!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
	}
}

[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 messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 260
Registered: April 2012
Senior Member
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.


Re: About the SWT_AWT bridge focus bugs [message #1811184 is a reply to message #1807690] Wed, 28 August 2019 10:16 Go to previous messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 260
Registered: April 2012
Senior Member
Are you still interested in working on SWT-AWT/Swing integration?

In my previous attempt to work in on it I made the Java bug report, but I doubt that that is the right direction. A better path would be something similar to the JavaFX-AWT/Swing integration.
Re: About the SWT_AWT bridge focus bugs [message #1814322 is a reply to message #1811184] Mon, 09 September 2019 13:35 Go to previous message
Djak Mising name is currently offline Djak Mising nameFriend
Messages: 16
Registered: November 2010
Junior Member
Hi,
thank you for your answers. I've seen your contributions before submitting the first post and also the Albireo Project. None of the workaround tested have worked for all issues.
We still have the bug and did a dirty workaround for Linux by calling Frame.setVisible(false) then Frame.setVisible(true) on an SWT mouse out event . It seems the only way for a Frame to loose the Focus using the bridge is when it becomes invisible or in background.
The results with the JavaFX integration are better and we thought about migrating to JavaFX or full SWT.
Previous Topic:Handler enable/disable not working
Next Topic:Unpacked Jars are still kept as Jars after being unpacked
Goto Forum:
  


Current Time: Fri Apr 19 19:54:07 GMT 2024

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

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

Back to the top