ToolTip: fixed left/right insets of multi-line tooltips so that they are the same as in single-line tooltips (BasicToolTipUI adds 3 to the left and right)

This commit is contained in:
Karl Tauber
2020-05-16 14:33:55 +02:00
parent a76b02b828
commit 069a4e8f0b

View File

@@ -103,7 +103,7 @@ public class FlatToolTipUI
for( String line : lines )
width = Math.max( width, SwingUtilities.computeStringWidth( fm, line ) );
return new Dimension( insets.left + width + insets.right, insets.top + height + insets.bottom );
return new Dimension( insets.left + width + insets.right + 6, insets.top + height + insets.bottom );
} else
return super.getPreferredSize( c );
}
@@ -119,8 +119,8 @@ public class FlatToolTipUI
List<String> lines = StringUtils.split( ((JToolTip)c).getTipText(), '\n' );
int x = insets.left;
int x2 = c.getWidth() - insets.right;
int x = insets.left + 3;
int x2 = c.getWidth() - insets.right - 3;
int y = insets.top - fm.getDescent();
int lineHeight = fm.getHeight();
JComponent comp = ((JToolTip)c).getComponent();