This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I think what he is referring to is needing to have a Window open that is always on top, but you still have access to the other Windows. I don't believe there is really a way to do this with JFrames/JDialogs without attachting a focus listener on the JDialog and when it loses focus, move it to the front of all the other windows. This will cause flickering and works pretty horribly. I don't know the requirements of your application, but if you could make it an MDI app, JInternalFrames are able to be put on the Palette Layer of a JDesktopPane which will give you the results you want. Just not in a Window outside of the main app.
Originally posted by Gregg Bolinger: I think what he is referring to is needing to have a Window open that is always on top, but you still have access to the other Windows.
You do a better job at reading into requirements than I. Your suggestion of an MDI app reminds me of a trick I used trying to simulate modal dialogs on an JApplet (there was something funky with JApplets and modal dialogs I guess. . .). Add an InternalFrame to the GlassPane rather than the ContentPane of a JApplet (applies to JFrame or JWindow as well). Set the GlassPane as a mouse listener and it intercepts any attempt to access the components on a ContentPane. The effect is that of a modal dialog within the application. When the dilaog is closed, remove the mouse listener from the GlassPane and clicks will be available to the ContentPane components. Maybe that's another option.
Joined: Feb 27, 2003
The reason for the question was in reference to a drag and drop implementation from a JTable to a JDialog. Since the JDialog would be covered once the dragsource was clicked on, I wanted a way to force the JDialog to stay on top as the dragTarget. I implemented a "class ComponentEvent extends ComponentAdapter" and included the componentHidden() method to trap hidding the JDialog and included the addComponentListener(new ComponentEvent()); line in the JDialog public constructor. I wanted to make a call to toFront(), but I'm not trapping the Hidden event for some reason.
Either way, I'm sure there's another way of dealing with the issue. Thanks for the responses.