I need to have a LWJGLCanvas appear under a JLayeredPane.
I have a demo of a client and server, But the only way I can get it to work is with a dialogue box asking for user+pass
This is my code:
public JPanel TheLogIntoScreen(){
JPanel Returned = new JPanel();
Returned.setLayout(new BorderLayout());
Returned.add(OtherHolderpane, BorderLayout.CENTER);
OtherHolderpane.setBounds(0, 0, 800, 600);
OtherHolderpane.add(LoginCanvas, new Integer(0), 0);
OtherHolderpane.add(LoginBox, new Integer(1), 0);
LoginCanvas = CanvasModels();//wtf?
LoginCanvas.setSize(800, 600);
LoginCanvas.setBackground(Color.green);
LoginCanvas.setBounds(0, 0, 800, 600);
LoginCanvas.add(CanvasModels());//wtf?
LoginCanvas.setOpaque(true);
Returned.setSize(Returned.getSize().width-1, Returned.getSize().width-1);
Returned.setSize(Returned.getSize().width+1, Returned.getSize().width+1);
return Returned;
}
public JPanel CanvasModels() {
JPanel Returned = new JPanel();
JTextPane testingpane = new JTextPane();
testingpane.setText("500x400");
// make the canvas:
DisplaySystem display = DisplaySystem.getDisplaySystem(LWJGLSystemProvider.LWJGL_SYSTEM_IDENTIFIER);
display.registerCanvasConstructor("AWT", LWJGLAWTCanvasConstructor.class);
canvas = (LWJGLCanvas) display.createCanvas(width, height);
canvas.setUpdateInput(true);
canvas.setTargetRate(60);
// add a listener... if window is resized, we can do something about it.
canvas.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent ce) {
doResize();
}
});
// Setup key and mouse input
KeyInput.setProvider(KeyInput.INPUT_AWT);
KeyListener kl = (KeyListener) KeyInput.get();
canvas.addKeyListener(kl);
AWTMouseInput.setup(canvas, false);
// Important! Here is where we add the guts to the panel:
impl = new MyImplementor(500, 400);
canvas.setImplementor(impl);
canvas.setBounds(0, 0, 500, 400);
Returned.add(canvas);
Returned.setSize(500, 400);
return Returned;
}
Here is my output when I start it though a double JLayeredPane
Jul 3, 2009 7:26:24 PM com.jme.input.joystick.DummyJoystickInput <init>
INFO: Joystick support is disabled
Jul 3, 2009 7:26:24 PM com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
Jul 3, 2009 7:26:24 PM com.jme.system.DisplaySystem getDisplaySystem
WARNING: SystemProvider already set
Exception in thread "main" java.lang.IllegalStateException: Provider may only be changed before input is created!
at com.jme.input.KeyInput.setProvider(KeyInput.java:613)
at ScarNastics.Client.TestClient.CanvasModels(TestClient.java:269)
at ScarNastics.Client.TestClient.TheLogIntoScreen(TestClient.java:160)
at ScarNastics.Client.TestClient.TheTOS(TestClient.java:136)
at ScarNastics.Client.TestClient.<init>(TestClient.java:67)
at ScarNastics.Client.TestClient.main(TestClient.java:60)
Java Result: 1
This is my results when I try to do just a simple JLayerPane
run:
Jul 3, 2009 7:28:05 PM com.jme.input.joystick.DummyJoystickInput <init>
INFO: Joystick support is disabled
Jul 3, 2009 7:28:05 PM com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
Jul 3, 2009 7:28:05 PM com.jme.system.DisplaySystem getDisplaySystem
WARNING: SystemProvider already set
Exception in thread "main" java.lang.IllegalStateException: Provider may only be changed before input is created!
at com.jme.input.KeyInput.setProvider(KeyInput.java:613)
at ScarNastics.Client.TestClient.CanvasModels(TestClient.java:269)
at ScarNastics.Client.TestClient.TheLogIntoScreen(TestClient.java:160)
at ScarNastics.Client.TestClient.<init>(TestClient.java:72)
at ScarNastics.Client.TestClient.main(TestClient.java:60)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
I can start the Canvas when I do a normal JPanel, but I want an UI ontop of it.
and I searched the forums to a similar questionaire. I got this one: http://www.jmonkeyengine.com/jmeforum/index.php?topic=6933.0
And someone said something like:
Core-Dump said:
is this because a heavyweight component will always draw over a lightweight component?
awt/jme canvas being heavyweight, swing being lightweight.
http://www.jmonkeyengine.com/jmeforum/index.php?topic=6926.0
And I have a picture of a Swing menu above it :
So If someone can show me how to implement a JPanel above a Canvas, this would be much appreciated.
Right now I have about 3 listeners so I can add text and update when I click an icon image in the invotory, So I think I might have to use a jME-GUI and not a jFrame-GUI, but i wana keep the listeners (as this way stops multi-login)
I havn't made my own Login screen models, so i just use the exampled spinning box lol...
Thanks for reading this long crap
~sonis