posted 21 years ago
I'm trying to add some components to a JDesktopPane in addition to some JInternalFrames such that the JInternalFrames will display in front of these components when they are not iconified. The problem is that JDesktopPane's layout manger is null and once you set it to any LayoutManager by calling setLayoutManager(...), then the JInternalFrames appear on the same layer as the other components in the JDesktopPane and will be aligned with them according to the chosen LayoutManager's policy (very weird looking). So I'm figuring that the only way to display a JPanel for example in the background is by specifically calling setBounds or setSize method on this JPanel. In this way the JInternalFrames will behave "normally". However the problem I am facing with this approach is that since I'm not using a LayoutManager, then this means that I If the JDesktopPane's parent is resized then the JPanel I have will not resize automatically because the LayoutMananager of the JDesktopPane is null. So The only solution I have though of is to have the listen for Component resizing events by having the Parent (JFrame) implement ComponentListener and listen for the the componentResized event and whenever the JFrame is resized I can resize the background JPanel to the intended size by calling setBounds on it inside this method. This approach works, but I have not found it to be reliable. Sometimes (I'm not sure which one occurs) either the resize event is not detected or the JPanel is not resized after the setBounds call, which results in some strange look. This problem occurs I would say 1/10 times when the JFrame is resized.
Does anybody have any idea on how to solve this problem?? ? Also if anybody knows how to use a LayoutManager with JDesktopPane with the requirement that the JInternalFrames associated with this JDesktopPane behave correctly, then please inform me how to do so.
Ahmed