ToolTip: fixed drop shadow for wide tooltips (issue #224; regression since fixed issue #142)

This commit is contained in:
Karl Tauber
2020-12-15 11:19:30 +01:00
parent 8bb8883e22
commit 5155ec93c9
4 changed files with 11 additions and 6 deletions

View File

@@ -23,6 +23,8 @@ FlatLaf Change Log
as row header in scroll pane. (issues #152 and #46)
- TableHeader: Fixed position of column separators in right-to-left component
orientation.
- ToolTip: Fixed drop shadow for wide tooltips on Windows and Java 9+. (issue
#224)
- SwingX: Fixed striping background highlighting color (e.g. alternating table
rows) in dark themes.

View File

@@ -271,16 +271,17 @@ public class FlatPopupFactory
// increase tooltip size if necessary because it may be too small on HiDPI screens
// https://bugs.openjdk.java.net/browse/JDK-8213535
if( contents instanceof JToolTip ) {
if( contents instanceof JToolTip && popupWindow == null ) {
Container parent = contents.getParent();
if( parent instanceof JPanel ) {
Dimension prefSize = parent.getPreferredSize();
if( !prefSize.equals( parent.getSize() ) ) {
Container panel = SwingUtilities.getAncestorOfClass( Panel.class, parent );
if( panel != null )
panel.setSize( prefSize ); // for medium weight popup
else
parent.setSize( prefSize ); // for light weight popup
Container mediumWeightPanel = SwingUtilities.getAncestorOfClass( Panel.class, parent );
Container c = (mediumWeightPanel != null)
? mediumWeightPanel // medium weight popup
: parent; // light weight popup
c.setSize( prefSize );
c.validate();
}
}
}

View File

@@ -487,6 +487,7 @@ public class FlatComponentsTest
//---- toggleButton1 ----
toggleButton1.setText("Enabled");
toggleButton1.setToolTipText("LOOOOOOOOOOOOOONG TEXT");
add(toggleButton1, "cell 1 2");
//---- toggleButton9 ----

View File

@@ -159,6 +159,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton1"
"text": "Enabled"
"toolTipText": "LOOOOOOOOOOOOOONG TEXT"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )