私はJava Swingを学んでいて、解決しようとしている視覚的な問題があります。
Windows 7 でシステム デフォルトのルック アンド フィールを使用すると、フローティング JToolBar の上に巨大な閉じるボタンと空のタイトル バーが表示されます。
フローティング ツールバーのみの画像 (バックグラウンドでアプリケーションを使用しない場合):
フローティング ツールバーの周囲の境界線とボタンを削除する方法はありますか? または、少なくともサイズを調整しますか?
nachokk からの提案とhttps://forums.oracle.com/thread/2279762にある次のスニプレットに感謝します。しかし、まだ機能していません。ドッキングを解除すると、ツールバーが非表示になります。
tbFile = new JToolBar();
tbFile.addHierarchyListener(new HierarchyListener() {
@Override
public void hierarchyChanged(HierarchyEvent e) {
if ((e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) == 0) return;
JToolBar bar = (JToolBar) e.getComponent();
if (!((BasicToolBarUI) bar.getUI()).isFloating()) return;
final Window topLevel = SwingUtilities.windowForComponent(bar);
if (topLevel instanceof JDialog) {
//((JDialog) topLevel).setVisible(false);
((JDialog) topLevel).setUndecorated(true);
//((JDialog) topLevel).setVisible(true);
}
}
});