Creating Transparent JFrame Breaks on Mac

I have a transparent unecorated JFrame that I set using AWTUtilities.setWindowOpaque(this, false) . On a JFrame , I have scrollpane; It works fine on Windows. On Mac, all JFrame dragged; so when I try to scroll the scroll by clicking and holding the mouse on the scroll bar, the whole frame moves instead of the finger of the scroll bar. I also tried using setBackground(new Color(0,0,0,0)) instead of setWindowOpaque() but it has the same problem. Any ideas on how to fix this?

+6
source share
1 answer

As suggested in this similar thread , try:

 getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE); 

If you decide to use this, the scroll bar will be used and the window will not be dragged. However, you can get stuck in a fixed window if you do not add MouseMotionListener and move the window around the mouseDragged() method using a call like frame.setLocation() .

Instead, you can force the user to click the arrow buttons on the scroll bar, rather than dragging the scroll bar ... But this is not the most user-friendly idea I have ever seen.

+1
source

Source: https://habr.com/ru/post/912396/


All Articles