mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
ComboBox and Spinner: move arrow slightly to the left if round borders are used on the component
This commit is contained in:
@@ -19,6 +19,7 @@ package com.formdev.flatlaf.ui;
|
||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
@@ -26,6 +27,7 @@ import java.awt.Shape;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.geom.Path2D;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import javax.swing.plaf.basic.BasicArrowButton;
|
||||
|
||||
@@ -152,6 +154,11 @@ public class FlatArrowButton
|
||||
if( y + rh >= height && y > 0 )
|
||||
y--;
|
||||
|
||||
// move arrow for round borders
|
||||
Container parent = getParent();
|
||||
if( parent instanceof JComponent && FlatUIUtils.hasRoundBorder( (JComponent) parent ) )
|
||||
x -= scale( parent.getComponentOrientation().isLeftToRight() ? 1 : -1 );
|
||||
|
||||
// paint arrow
|
||||
g.setColor( enabled
|
||||
? (isHover() && hoverForeground != null ? hoverForeground : foreground)
|
||||
|
||||
@@ -168,6 +168,10 @@ public class FlatUIUtils
|
||||
: 0;
|
||||
}
|
||||
|
||||
public static boolean hasRoundBorder( JComponent c ) {
|
||||
return getBorderArc( c ) >= c.getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets rendering hints used for painting.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user