Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-11-06 14:19:33 -0500
committerEric Williams2019-11-06 14:30:51 -0500
commit4306493f49abc761d7ecc73de3a6b13451b21bf0 (patch)
tree06986302ff9e943d687d2235871d4937d11e28a6
parent12688564aa61bc1acdbefae82b591a84767f8dca (diff)
downloadeclipse.platform.swt-4306493f49abc761d7ecc73de3a6b13451b21bf0.tar.gz
eclipse.platform.swt-4306493f49abc761d7ecc73de3a6b13451b21bf0.tar.xz
eclipse.platform.swt-4306493f49abc761d7ecc73de3a6b13451b21bf0.zip
Bug 550517: [GTK3] Swing components keep the focus when coming back to SWT widgets
Call proper constructor in XEmbeddedFrame which sets supportsXEmbed to true. Coincidently the is the same solution to bug 548661. I have merged Nikita's patch for bug 548661 (thanks Nikita!) and will upload only the snippet in this patch. Tested on GTK3.24 and Fedora 31 on X11 with the snippet attached. No AllNonBrowser JUnit tests fail. Change-Id: I8c2e30b90481c2b5bb108f447ad89b167a06f7d9 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug550517_SwingComponentFocus.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug550517_SwingComponentFocus.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug550517_SwingComponentFocus.java
new file mode 100644
index 0000000000..7638dbef04
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug550517_SwingComponentFocus.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Olivier Prouvost and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Olivier Prouvost - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import java.awt.Frame;
+
+import javax.swing.JComboBox;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.awt.SWT_AWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+
+public class Bug550517_SwingComponentFocus {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText("Snippet 109");
+ shell.setSize(600, 250);
+ shell.setLayout(new GridLayout(1, false));
+
+
+ Text txtInput = new Text(shell, SWT.BORDER);
+ txtInput.setText("This is a text using swt");
+ txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Create the swing widgets in a group
+ Group group = new Group(shell, SWT.BORDER);
+ group.setText("Swing widgets");
+ group.setLayout(new FillLayout());
+ group.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
+
+ Composite composite = new Composite(group, SWT.EMBEDDED | SWT.NO_BACKGROUND);
+ Frame frame = SWT_AWT.new_Frame(composite);
+
+ JPanel p = new JPanel();
+
+ JTextField tf = new JTextField();
+ tf.setText("Text in a swing component keeps the focus on Linux");
+ p.add(tf);
+
+ JComboBox<String> cb = new JComboBox<>(new String[] { "choice 1", "choice 2", "choice 3"});
+ cb.setEditable(true);
+
+ p.add(cb);
+
+ frame.add(p);
+ frame.pack();
+
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+
+} \ No newline at end of file

Back to the top