I have a transparent undecorated JFrame
that I set using AWTUtilities.setWindowOpaque(this, false)
. On the JFrame
, I have a scrollpane; it works perfectly on Windows. On the Mac, the whole JFrame
is draggable; so when I try to scroll through the scrollpane by clicking and holding the mouse on the scrollbar, the entire frame moves instead of the scrollbar thumb. I also tried to use setBackground(new Color(0,0,0,0))
instead of setWindowOpaque()
, but it has the same problem. Any ideas on how to fix this?
As suggested in this similar thread, try:
getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE);
If you choose to use this, the scrollbar will be usable and the window won't drag. However, you may be stuck with an immovable window, unless you add a MouseMotionListener
and move the window around in the mouseDragged()
method using a call like frame.setLocation()
.
Instead, you might be able to force the user to click on the scrollbar's arrow buttons, rather than drag the scrollbar itself... But that's not the most user-friendly idea I've ever seen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With