How do I make my Java 7 OSX App draggable on toolbar only ?

Paul Taylor paul_t100 at fastmail.fm
Mon Nov 4 01:05:46 PST 2013


On 31/10/2013 17:30, Paul Taylor wrote:
> Things were working okay with Java 6 ( and some custom libs) but now 
> by default a Java 7 application is only movable on Mac if you click 
> near the top of the window (like on Windows), however if I set
>
> toolbar.getRootPane().putClientProperty("apple.awt.draggableWindowBackground") 
>
>
> I can then move the window by dragging on the toolbar. Unfortunately 
> because this property is applied to the rootpane, and then is just one 
> rootpane for the frame that the whole applications is a part of the 
> window moves where-ever I drag on it, I only want to be able to drag 
> on it in the toolbar.
>
> The main part of my application is a JTable and I really don't want 
> the window to be moved when I dragclick here because it causes lots of 
> problems such as I can now no longer reorder by table columns by 
> dragging the table headers because that just moves the whole window. 
> How can I limit movement to either:
>
> 1. Only the JToolbar
> 2. Everywhere except the Jtable
>
> whichever is easiest.
>
> thanks Paul
>
Nevermind I found a solution, I used UnifiedToolbar from 
thehttp://code.google.com/p/macwidgets/ project with Java 6. Since 
moving to Java 7 and no longer using UnifiedToolbar I couldn't see a 
solution but delving into their code simply using WindowsDragger class 
works perfectly well

i.e.

     new WindowsDragger(frame, toolbar);
     new WindowsDragger(frame, statusbar)

In contrast the "apple.awt.draggableWindowBackground" option is only 
really useful if happy for the whole frame to be draggable.

Paul




More information about the macosx-port-dev mailing list