JMEDesktop/JMEDesktopState question

Im messing arround with JMEDesktop(State) for the first time and I have 2 questions


  1. When adding Swing components you use the GameTaskQueueManager to inject them into the openGL Thread. rRght now I have the following addition inside the Callable



//Add user/pass box
JPasswordField userField = new JPasswordField("test", 16);
JTextField passwordField = new JTextField("test",16);
desktopState.getDesktop().getJDesktop().add(userField);
desktopState.getDesktop().getJDesktop().add(passwordField);
userField.setLocation(50,10);
passwordField.setLocation(70,10);
userField.setPreferredSize(userField.getPreferredSize());
passwordField.setPreferredSize(passwordField.getPreferredSize());



However they aren't displayed. This code can litterly be copy&pasted to TestJMEDesktopState, since im using that class to test this out. Whenever I add an other component like a button (just like the quit button) it does display


2) When I create a JPanel and paste an image on it, I can nicely see my JPanel, however the buttons dont show up. Most likely they are hidden behind. Is there any way to alter their Z-axis?


ImageIcon backGround= new ImageIcon(image);
ImagePanel panel = new ImagePanel(backGround.getImage());
desktopState.getDesktop().getJDesktop().add(panel);

class ImagePanel extends JPanel {

  private Image img;

  public ImagePanel(String img) {
    this(new ImageIcon(img).getImage());
  }

  public ImagePanel(Image img) {
    this.img = img;
    Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
    setPreferredSize(size);
    setMinimumSize(size);
    setMaximumSize(size);
    setSize(size);
    setLayout(null);
  }

  public void paintComponent(Graphics g) {
    g.drawImage(img, 0, 0, null);
  }
   
}



  1. Modifying (and even reading) JComponents must be done from the Swing-Thread (AWT Event Queue), not from the gl thread.
  2. Not sure what you are asking… it's Swing
irrisor said:

1) Modifying (and even reading) JComponents must be done from the Swing-Thread (AWT Event Queue), not from the gl thread.
2) Not sure what you are asking... it's Swing


1) Does TestJMEDesktopState also work with a swing thread? Im using that class as refference to build my own JMEdesktop but fail to see where the swing thread is being used when adding the components to the desktop.
2)Basically, the Z-order of my components is not right. Perhaps this is related to #1?

I wish I could look at it right now but can't. I'll look at it when I can and add an edit to my post.