mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
Window decorations: do not center window title if embedded menu bar is empty or has no menus at left side, but some components at right side (issue #558)
This commit is contained in:
12
CHANGELOG.md
12
CHANGELOG.md
@@ -13,11 +13,13 @@ FlatLaf Change Log
|
||||
- `HiDPIUtils.paintAtScale1x()` now supports rotated graphics. (issue #557)
|
||||
- Typography: No longer use `Consolas` or `Courier New` as monospaced font on
|
||||
Windows because they have bad vertically placement.
|
||||
- Native window decorations (Windows 10/11 only): Do not use window decorations
|
||||
if system property `sun.java2d.opengl` is `true` on Windows 10. (issue #540)
|
||||
- Native window decorations (Windows 10 only): Fixed missing top window border
|
||||
in dark themes if window drop shadows are disabled in system settings. (issue
|
||||
#554)
|
||||
- Native window decorations (Windows 10/11 only):
|
||||
- Do not center window title if embedded menu bar is empty or has no menus at
|
||||
left side, but some components at right side. (issue #558)
|
||||
- Do not use window decorations if system property `sun.java2d.opengl` is
|
||||
`true` on Windows 10. (issue #540)
|
||||
- Fixed missing top window border in dark themes if window drop shadows are
|
||||
disabled in system settings. (issue #554; Windows 10 only)
|
||||
|
||||
|
||||
## 2.3
|
||||
|
||||
@@ -899,7 +899,8 @@ debug*/
|
||||
|
||||
@Override
|
||||
protected void paintEnabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
|
||||
boolean hasEmbeddedMenuBar = hasVisibleEmbeddedMenuBar( rootPane.getJMenuBar() );
|
||||
JMenuBar menuBar = rootPane.getJMenuBar();
|
||||
boolean hasEmbeddedMenuBar = hasVisibleEmbeddedMenuBar( menuBar ) && hasMenus( menuBar );
|
||||
int labelWidth = l.getWidth();
|
||||
int textWidth = labelWidth - (textX * 2);
|
||||
int gap = UIScale.scale( menuBarTitleGap );
|
||||
@@ -925,6 +926,24 @@ debug*/
|
||||
|
||||
super.paintEnabledText( l, g, s, textX, textY );
|
||||
}
|
||||
|
||||
private boolean hasMenus( JMenuBar menuBar ) {
|
||||
// check whether menu bar is empty
|
||||
if( menuBar.getComponentCount() == 0 || menuBar.getWidth() == 0 )
|
||||
return false;
|
||||
|
||||
// check whether menu bar has a leading glue component
|
||||
// (no menus/components at left side)
|
||||
Component horizontalGlue = findHorizontalGlue( menuBar );
|
||||
if( horizontalGlue != null ) {
|
||||
boolean leftToRight = getComponentOrientation().isLeftToRight();
|
||||
if( (leftToRight && horizontalGlue.getX() == 0) ||
|
||||
(!leftToRight && horizontalGlue.getX() + horizontalGlue.getWidth() == menuBar.getWidth()) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//---- class Handler ------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user