简体   繁体   English

如何使Java 7 OSX App仅可在工具栏上拖动

[英]How do I make my Java 7 OSX App draggable on toolbar only

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 默认情况下,如果您单击窗口顶部附近(例如Windows),则Java 7应用程序只能在Mac上移动,但是如果我设置了

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 whereever 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. 我的应用程序的主要部分是一个JTable,我真的不希望在我拖动click时移动窗口,因为它会引起很多问题,例如我现在无法再通过拖动表头来按表列重新排序,因为移动整个窗口。 How can I limit movement to either. 我怎样才能限制运动。

  1. Only the JToolbar 只有JToolbar
  2. Everywhere except the Jtable 除Jtable之外的所有地方

whichever is easiest. 以最简单的为准。

Found a solution, I used UnifiedToolbar from the MacWidgets project with Java 6. Since moving to Java 7 and no longer using UnifiedToolbar I couldn't see a solution but delving into the code simply using WindowsDragger class works perfectly well 找到一个解决方案后,我将MacWidgets项目中的UnifiedToolbar与Java 6一起使用。由于移至Java 7并不再使用UnifiedToolbar,所以我看不到解决方案,而仅使用WindowsDragger类研究代码就可以很好地工作

ie

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. 相反,“ apple.awt.draggableWindowBackground”选项仅在希望整个框架都可拖动时才真正有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM