我正在使用swingx庫,在 Windows 上,我現在正朝著在所有平臺上使用
這是因為我使用的是 swingxJXStatusBar組件,它具有一些外觀和感覺增強功能,包括一些用于背景的 Windows 特定影像
例如 swingx\swingx-core\src\main\resources\org\jdesktop\swingx\plaf\windows\resources\silver-statusbar-left.png
嘗試更改組件的背景顏色或我添加到它的標簽沒有效果。
所以我認為最好的辦法是停止使用JXStatusBar并只使用 JPanel,但繼續使用相同的方式添加組件JXStatusBar.Constraint
component = new JPanel();
.....
JXStatusBar.Constraint c1 = new JXStatusBar.Constraint();
c1.setFixedWidth(100);
component.add(statusLabel, c1);
JXStatusBar.Constraint c2 = new JXStatusBar.Constraint(JXStatusBar.Constraint.ResizeBehavior.FILL);
c2.setFixedWidth(200);
JXStatusBar.Constraint c4 = new JXStatusBar.Constraint(130);
component.add(filesLoadedLabel, c2);
component.add(filesFilteredLabel, c2);
component.add(tagBrowserFilterLabel, c2);
component.add(activeFiltersLabel, c2);
component.add(mbDelayLabel, c4);
component.add(memoryLabel, c4);

However as the screenshot above shows this doesnt work properly, probably because Im using the wrong LayoutManager but I cant work out what LayoutManager JXStatusBar is using I cannot see one defined in the code.
So my question is either:
- What Layout Manager do I need to set JPanel to to align same way?
- What is the most similar LayoutManager I can use instead to have the same effect?
Edit
Okay so I have got it basically working by hacking internal LayoutManager class from BasicStatusBarUI but I think I would prefer to just use a standard LayoutManager, is that possible ?

uj5u.com熱心網友回復:
添加flatlaf-swingx.jar到您的專案中,然后JXStatusBar使用 FlatLaf 正常作業:

請參閱SwingX 的 FlatLaf 插件和 問題 #492
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/439794.html
標籤:java swing layout-manager swingx flatlaf
上一篇:在Swing中漸變顏色?
下一篇:如何檢查檔案是否損壞?
