ComboBox: use small border if used as table editor

This commit is contained in:
Karl Tauber
2019-10-15 10:35:06 +02:00
parent a8b8cbdf8c
commit 41df9859ad
3 changed files with 15 additions and 3 deletions

View File

@@ -1,6 +1,11 @@
FlatLaf Change Log
==================
## Unreleased
- ComboBox: Use small border if used as table editor.
## 0.13
- Added developer information to Maven POM for Maven Central publishing.

View File

@@ -72,9 +72,10 @@ public class FlatBorder
try {
FlatUIUtils.setRenderingHints( g2 );
float focusWidth = getFocusWidth();
boolean isCellEditor = FlatUIUtils.isTableCellEditor( c );
float focusWidth = isCellEditor ? 0 : getFocusWidth();
float borderWidth = getBorderWidth( c );
float arc = getArc();
float arc = isCellEditor ? 0 : getArc();
if( isFocused( c ) ) {
g2.setColor( getFocusColor( c ) );
@@ -134,7 +135,8 @@ public class FlatBorder
@Override
public Insets getBorderInsets( Component c, Insets insets ) {
float ow = getFocusWidth() + getLineWidth();
boolean isCellEditor = FlatUIUtils.isTableCellEditor( c );
float ow = (isCellEditor ? 0 : getFocusWidth()) + getLineWidth();
insets = super.getBorderInsets( c, insets );
insets.top = Math.round( scale( (float) insets.top ) + ow );

View File

@@ -17,6 +17,7 @@
package com.formdev.flatlaf.ui;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
@@ -80,6 +81,10 @@ public class FlatUIUtils
return (c instanceof ColorUIResource) ? new Color( c.getRGB(), true ) : c;
}
public static boolean isTableCellEditor( Component c ) {
return c instanceof JComponent && Boolean.TRUE.equals( ((JComponent)c).getClientProperty( "JComboBox.isTableCellEditor" ) );
}
/**
* Sets rendering hints used for painting.
*/