This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Wondering if there is any way that the JPopupMenu can be set so that if you click outside of the menu, it doesn't cancel (hide). I want it to stay until I tell it to disappear (or the frame is minimized).
Also, any way to remove the drop shadow that is visible on my Mac for the JPopupMenu? I've setOpaque(false) and setBorderPainted(false), but still see a drop shadow.
Second edit: This prevents the popup from closing if you click elsewhere in the JFrame (or more correctly, its content pane). Clicking a menu item hides the popup; if that too is undesired, see my blog post Keeping Menus Open.
I don't think there's any reasonable, LaF independent way to keep the popup open if the mouse is clicked outside the Java application or if the window is resized or minimized.
If you opt for this solution, you may need to iterate recursively over all components and set the client property.
There are no new questions, but there may be new answers.
I'm trying to overcome some heavyweight / lightweight issues with regard to OpenGL. I'm trying to display a JEditorPane on top of an OpenGL scene. I've been able to do this pretty well by placing the JScrollPane inside of a JPopupMenu, but the problem is if I click on the scene behind the JEditorPane (PopupMenu), I don't want it to disappear (cancel). I also don't want it to disappear if you click on it (this hasn't been a problem). I only want it to disappear if I call setVisible(false) or if the frame is minimized (automatic). It's a fullscreen app, so not worried about outside frame clicks. So I'm not really using it as a button or menu, but as a way to overcome other issues. Here is my code thus far, using Processing as the IDE.
A JFrame and JDialog drop behind the OpenGL scene (not sure about JWindow - haven't got that working yet) if the main frame is Always on Top. So you then have to do some AlwaysOnTop trick to make sure it doesn't fall behind. You loose keyboard control to the main scene and clicking on the main scene changes the focus. I don't have these problems with the PopupMenu. I just need to prevent it from closing itself if I click outside of the menu. I'll keep testing with the other options though..
Running into a problem... while this dialog screen is up, I make a call to a FileDialog. It uses a javax.swing.SwingUtilities.invokeAndWait(). With the JDialog, it no longer works. I've tried to hide the JDialog prior to running the FileDialog, but no go. Any tricks here? I've tried an invokeLater() but this won't stay on top of the screen.
Specifying java.awt.Dialog.ModalityType.MODELESS helped it pop through, but it locks up afterward if I click to save more than once.
Specifying the JDialog as the parent had mixed results, sometimes it would show and sometimes not.. always locking up if I clicked the button more than once.
Update: MODELESS is also mixed, sometimes it locks up on the first click without the dialog. Even tried both.. MODELESS and JDialog.. same.
I restarted my IDE and now it seems to be working... Uggg.. ok, it's late. Thank you so much for you help. I'll let you know what I find out tomorrow.
Update: now it's not working again.. this thing is so odd.