JDesktopPane in a UIWindow?

Anyone no how to get it working? i get:

java.lang.IllegalArgumentException: adding a window to a container

Maybe im pushing the Xith swing angle a little to far?

here me code- nice and simple:


public class InternalFrame extends UIWindow {
  public InternalFrame(int width, int height, boolean includeExitButton) {
    super(width, height, true, true);
    
    JDesktopPane desktop = new JDesktopPane();
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    
    JFrame j = new JFrame("hello there");
    j.setBounds(30, 30, 200, 400);
    j.setVisible(true);
    
    desktop.add(j);
    
    setRoot(desktop);
  }
}

That’s a swing only question:

You cannot add a JFrame to a JComponent. That is impossible. The other way around works if you use

yourJFrame.getContentPane.add(yourJComponent);

In your case you can only use any subclass of JComponent to add to your DesktopPane.

If you need a frame like structure take JInternalFrame which is a subclass of JComponent and is a lightweight version to support features like JFrame.

thought it maybe. thanks for the reply dude. but i get nothing at all showing when i do it this way:


    JDesktopPane desktop = new JDesktopPane();
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);

    JInternalFrame jif = new JInternalFrame("hello there");
    jif.setBounds(0, 0, 200, 200);
    jif.setVisible(true);
    jif.show();
    
    desktop.add(jif);
    setRoot(desktop);

see anthing im doing wrong? i been messing with this for awhile and think im just being a muppet…

When I tried my first steps with swing & xith for the first time it was not working but after that I set any bounds of any object - that is all parent objects of your internal frame should have them set also.

If that does not help you may try a simpler example without internal frames and desktop pane. A simple jpanel should work (maybe add a label also).

PS: I remember not having success when trying to move internal frames on the UIOverlay. Event handling is not as expected (the canvas always want to be the receiver/originator of events - had a hard time when making a workaround for textfields WITH real working eventlisteners - thread Prob with Xith, Swing, textfield + listeners http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1079039524). The other way around seems easier (Xith within swing gui: see thread "Xith and Swing ")

BTW: as far as I know show and setVisible are equal (though show is deprecated).

cool it was a setBounds thing… i should have spotted that. cheers… and more importently thanks for the pointer to Events. sounds like alot of hassle awaiting me there next :)… me internalFrames are there now… but with no events being passed for draging them. and them events as u say are just being passed directly to xith…

thanks again