2

How to add a Shell to a jPanel. I created a shell with components and now I want to add it to a jPanel called jPanel1. How can I do this?

private Shell sShell = null;
sShell = new Shell();
Hasitha Jayawardana
  • 2,326
  • 4
  • 18
  • 36
  • JPanel is Swing which is a different UI from SWT, mixing SWT and Swing is very difficult. Stick to one GUI system - choose either Swing or SWT (or JavaFX). – greg-449 Feb 10 '18 at 21:19

1 Answers1

3

In the Eclipse Standard Widget Toolkit (SWT) a Shell (org.eclipse.swt.widgets.Shell) represents a window, whereas a JPanel (javax.swing.JPanel) represents only a container in the Java Swing GUI widget toolkit.

Therefore it is not possible to add a org.eclipse.swt.widgets.Shell to a javax.swing.JPanel.

It is not recommended to mix different GUI widget toolkits. There are only rare cases where this make sense (e. g. using a SWT browser widget in Swing). If you want to use Swing, see e. g. Lesson: Getting Started with Swing, if you want to use SWT, these SWT snippets might be helpful.

    -
howlger
  • 31,050
  • 11
  • 59
  • 99