mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 15:27:16 -06:00
fixed white lines at bottom and right side of window (in dark themes on HiDPI screens with scaling enabled)
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
FlatLaf Change Log
|
FlatLaf Change Log
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
## 1.3-SNAPSHOT
|
||||||
|
|
||||||
|
#### Fixed bugs
|
||||||
|
|
||||||
|
- Fixed white lines at bottom and right side of window (in dark themes on HiDPI
|
||||||
|
screens with scaling enabled).
|
||||||
|
|
||||||
|
|
||||||
## 1.2
|
## 1.2
|
||||||
|
|
||||||
#### New features and improvements
|
#### New features and improvements
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import java.awt.Insets;
|
|||||||
import java.awt.LayoutManager;
|
import java.awt.LayoutManager;
|
||||||
import java.awt.LayoutManager2;
|
import java.awt.LayoutManager2;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
|
import java.awt.event.HierarchyEvent;
|
||||||
|
import java.awt.event.HierarchyListener;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
@@ -79,6 +81,7 @@ public class FlatRootPaneUI
|
|||||||
|
|
||||||
private Object nativeWindowBorderData;
|
private Object nativeWindowBorderData;
|
||||||
private LayoutManager oldLayout;
|
private LayoutManager oldLayout;
|
||||||
|
private HierarchyListener hierarchyListener;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatRootPaneUI();
|
return new FlatRootPaneUI();
|
||||||
@@ -136,6 +139,39 @@ public class FlatRootPaneUI
|
|||||||
c.putClientProperty( "jetbrains.awt.windowDarkAppearance", FlatLaf.isLafDark() );
|
c.putClientProperty( "jetbrains.awt.windowDarkAppearance", FlatLaf.isLafDark() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installListeners( JRootPane root ) {
|
||||||
|
super.installListeners( root );
|
||||||
|
|
||||||
|
if( SystemInfo.isJava_9_orLater ) {
|
||||||
|
// On HiDPI screens, where scaling is used, there may be white lines at the
|
||||||
|
// bottom and at the right side of the window when it is initially shown.
|
||||||
|
// This is very disturbing in dark themes, but hard to notice in light themes.
|
||||||
|
// Seems to be a rounding issue when Swing adds dirty region of window
|
||||||
|
// using RepaintManager.nativeAddDirtyRegion().
|
||||||
|
hierarchyListener = e -> {
|
||||||
|
if( (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 &&
|
||||||
|
rootPane.getParent() instanceof Window )
|
||||||
|
{
|
||||||
|
// add whole root pane to dirty regions when window is initially shown
|
||||||
|
rootPane.getParent().repaint( rootPane.getX(), rootPane.getY(),
|
||||||
|
rootPane.getWidth(), rootPane.getHeight() );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
root.addHierarchyListener( hierarchyListener );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void uninstallListeners( JRootPane root ) {
|
||||||
|
super.uninstallListeners( root );
|
||||||
|
|
||||||
|
if( SystemInfo.isJava_9_orLater ) {
|
||||||
|
root.removeHierarchyListener( hierarchyListener );
|
||||||
|
hierarchyListener = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 1.1.2
|
* @since 1.1.2
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user