I am trying to design a small game, and using a JInternalFrame to display the Inventory. The problem I am having though, is that when I minimize the InternalFrame, the icon in the bottom left corner automatically hides behind the JPanel that is also added to the JDesktopPane. When I drag the window down (making the window larger vertically), the white DesktopPane becomes visible below the default gray JPanel. Also, as I drag down, the icon of the InternalFrame is revealed. I tried to post pictures but I'm new to the site so I can't :(.
I've tried using the moveToFront() and toFront() methods and tried overriding the InternalFrameListener for iconifying the frame, but nothing has worked. If you think I am using a bad design feel free to tell me - I'm just a student and I don't have too much knowledge of common practice.
Here's my code
public class GameTester extends JFrame {
private JDesktopPane pane;
private Inventory i; //class that extends JInternalFrame
public static void main(String[] args) {
GameTester frame = new GameTester();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1280, 720);
}
public GameTester() {
setFocusable(true);
i = new Inventory("Inventory");
GamePanel g = new GamePanel();
g.setBounds(0, 0, 1280, 720);
pane = new JDesktopPane();
pane.add(i);
setContentPane(pane);
getContentPane().add(g);
}
}