-
Bug
-
Resolution: Fixed
-
P2
-
7
-
b25
-
x86
-
windows_xp
-
Not verified
OS: Windows XP
JDK: Current AWT workspace - JDK 7.0 b18+
An SWT application that embeds AWT hangs on its starting.
Compile and run the testcase provided.
EXPECTED:
The SWT shell will open.
ACTUAL:
Nothing is shown. The app hangs.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
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;
public class FrameFocusAndActivationIssue {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Parent shell");
shell.setLayout(new FillLayout());
Composite composite = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED);
final Frame swingFrame = SWT_AWT.new_Frame(composite);
swingFrame.setLayout(new BorderLayout());
Panel awtPanel = new Panel(new BorderLayout());
awtPanel.setLayout(new BorderLayout());
swingFrame.add(awtPanel, BorderLayout.CENTER);
JPanel panel = new JPanel();
JTextField textField = new JTextField("First Text Field", 30);
textField.setToolTipText("text field 1 tip");
textField.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
System.out.println("text field 1 gained focus: ");
System.out.println("other component: " + e.getOppositeComponent());
System.out.println("params: " + e.paramString());
}
public void focusLost(FocusEvent e) {
System.out.println("text field 1 lost focus: ");
System.out.println("other component: " + e.getOppositeComponent());
System.out.println("params: " + e.paramString());
}
});
final JTextField textField2 = new JTextField("Next Text Field", 30);
textField2.setToolTipText("text field 2 tip");
textField2.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
System.out.println("text field 2 gained focus: ");
System.out.println("other component: " + e.getOppositeComponent());
System.out.println("params: " + e.paramString());
}
public void focusLost(FocusEvent e) {
System.out.println("text field 2 lost focus: ");
System.out.println("other component: " + e.getOppositeComponent());
System.out.println("params: " + e.paramString());
}
});
panel.add(textField);
panel.add(textField2);
awtPanel.add(panel);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
textField2.requestFocusInWindow();
}
});
shell.setSize(600, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
---------- END SOURCE ----------
JDK: Current AWT workspace - JDK 7.0 b18+
An SWT application that embeds AWT hangs on its starting.
Compile and run the testcase provided.
EXPECTED:
The SWT shell will open.
ACTUAL:
Nothing is shown. The app hangs.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
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;
public class FrameFocusAndActivationIssue {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Parent shell");
shell.setLayout(new FillLayout());
Composite composite = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED);
final Frame swingFrame = SWT_AWT.new_Frame(composite);
swingFrame.setLayout(new BorderLayout());
Panel awtPanel = new Panel(new BorderLayout());
awtPanel.setLayout(new BorderLayout());
swingFrame.add(awtPanel, BorderLayout.CENTER);
JPanel panel = new JPanel();
JTextField textField = new JTextField("First Text Field", 30);
textField.setToolTipText("text field 1 tip");
textField.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
System.out.println("text field 1 gained focus: ");
System.out.println("other component: " + e.getOppositeComponent());
System.out.println("params: " + e.paramString());
}
public void focusLost(FocusEvent e) {
System.out.println("text field 1 lost focus: ");
System.out.println("other component: " + e.getOppositeComponent());
System.out.println("params: " + e.paramString());
}
});
final JTextField textField2 = new JTextField("Next Text Field", 30);
textField2.setToolTipText("text field 2 tip");
textField2.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
System.out.println("text field 2 gained focus: ");
System.out.println("other component: " + e.getOppositeComponent());
System.out.println("params: " + e.paramString());
}
public void focusLost(FocusEvent e) {
System.out.println("text field 2 lost focus: ");
System.out.println("other component: " + e.getOppositeComponent());
System.out.println("params: " + e.paramString());
}
});
panel.add(textField);
panel.add(textField2);
awtPanel.add(panel);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
textField2.requestFocusInWindow();
}
});
shell.setSize(600, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
---------- END SOURCE ----------
- relates to
-
JDK-6492970 REG: Modeless dialog not getting active the first time when the parent frame is non-focusable, Win32
-
- Closed
-