Search code examples
javac#winformsawtembed

Embedding Java SWT/AWT bridge into winform form


I created a winform form with a button and when I click on the button I´m invoking a Java AWT (.jar) process. After that I embed this process into a Panel using SetParent(...). The code:

var procStartInfo = new ProcessStartInfo();
procStartInfo.WindowStyle = ProcessWindowStyle.Normal;
procStartInfo.FileName = "file.jar";
var process = Process.Start(procStartInfo);

var container = new FormContainer();
container.Show();

Panel p = new Panel();
container.Controls.Add(p);

SetParent(process.MainWindowHandle, p.Handle);

The problem is when I embed the jar... the textboxes are not responding to any keypress event. I supose that the issue is related to the Java Swing application. Using any other moderm Java application every thing is working fine

Any idea if I need anything else to solve that problem


Solution

  • The problem is the bridge focus handler. In the java 1.8 version, the focus handler use multithread code and it seem that is it the problem in the java embeded application. We remove the async code and it works fine