Can't get a Canvas working in a custom JPanel

I have been trying to get a simple scene rendered in a JPanel. The guides I have see focus on directly building the Frame and components within the project’s run() method, but I want a more generic panel that I can reuse across multiple applications. What I want is a little backwards from what the examples show - my main GUI is external and trying to import the jme scene rather than building the GUI with the scene included. Basically, I want to be able to have 3 tiers:

Overall GUI → myJmeJPanel (extends JPanel) → myScene(extends SimpleApplication)

All of the 3d work should be hidden and totally isolated from the overall GUI and it should not see anything more than the creation of a custom JPanel, or equivalent functionality.

I have to work with multiple, fairly simple scenes that each extend SimpleApplication. I also have multiple different places in the GUI that will need the 3d components at different times. The scenes are simple, and I don’t have much going on in the scene (rotations, translations, etc), so performance is not my biggest concern.

Basically, I can’t figure out how to get a call that basically does:

ExternalGUI.add(new myJmeJPanel());

The standard sample forces me to attach the JPanel within the Runnable and does not provide a way that I can find to attach to the Class I wrote which extends JPanel. I also looked at the Scene Editor course[]=canvas&s[]=jpanel

Several of the imports in that example are not supported (or I could not find them) in jme3... Display and Impl classes in particular. This is the closest I have seen to what I need, but I can't figure out how to replace those classes.

My basic desire is to simply be able to replace the standard JFrame code with a ".add(ctx.getCanvas())", which clearly does not work within the Runnable.
In the code below, GLSurfacePanel is the panel I want in between the main GUI and the Scene. GLSurface is the scene (extends SimpleApplication). I have a separate GUI that basically just does:

JPanel localPane =new GLSurfacePanel();

public class GLSurfacePanel extends javax.swing.JPanel {

public GLSurfacePanel() {
initComponents(); //just sets the Layout right now

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {
AppSettings settings = new AppSettings(true);

GLSurface canvasApplication = new GLSurface();
JmeCanvasContext ctx = (JmeCanvasContext) canvasApplication.getContext();
Dimension dim = new Dimension(640, 480);

JFrame window = new JFrame("Test Application");




If I leave the JFrame in, then, obviously, an extra frame opens that runs my scene. If I comment out all of the frame items, then I can't figure out how to get the ctx.getCanvas() call into the JPanel rather than the Runnable. I suspect I am trying an approach that is totally inappropriate, but don't know enough about managing this to sort it out.

Can anyone point me in the right direction to create a custom JPanel that can fit these needs?

I found a sample that covers almost exactly what I wanted. It puts the Canvas into a tabbed pane. For anyone else that has the same need, simply look at the code in the link and replace the string:

private static final String appClass = “”;

with your class that extends SimpleApplication.