mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
ScrollPane: allow specifying scroll pane border arc for multi-line text components, lists, tables and trees
This commit is contained in:
@@ -28,7 +28,6 @@ import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.basic.BasicBorders;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
@@ -195,8 +194,7 @@ public class FlatBorder
|
||||
protected boolean isEnabled( Component c ) {
|
||||
if( c instanceof JScrollPane ) {
|
||||
// check whether view component is disabled
|
||||
JViewport viewport = ((JScrollPane)c).getViewport();
|
||||
Component view = (viewport != null) ? viewport.getView() : null;
|
||||
Component view = FlatScrollPaneUI.getView( (JScrollPane) c );
|
||||
if( view != null && !isEnabled( view ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,12 @@ package com.formdev.flatlaf.ui;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
@@ -26,6 +31,10 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
* Border for {@link javax.swing.JScrollPane}.
|
||||
*
|
||||
* @uiDefault ScrollPane.arc int
|
||||
* @uiDefault ScrollPane.List.arc int
|
||||
* @uiDefault ScrollPane.Table.arc int
|
||||
* @uiDefault ScrollPane.TextComponent.arc int
|
||||
* @uiDefault ScrollPane.Tree.arc int
|
||||
|
||||
* @author Karl Tauber
|
||||
* @since 3.3
|
||||
@@ -35,6 +44,22 @@ public class FlatScrollPaneBorder
|
||||
{
|
||||
@Styleable protected int arc = UIManager.getInt( "ScrollPane.arc" );
|
||||
|
||||
private boolean isArcStyled;
|
||||
private final int listArc = FlatUIUtils.getUIInt( "ScrollPane.List.arc", -1 );
|
||||
private final int tableArc = FlatUIUtils.getUIInt( "ScrollPane.Table.arc", -1 );
|
||||
private final int textComponentArc = FlatUIUtils.getUIInt( "ScrollPane.TextComponent.arc", -1 );
|
||||
private final int treeArc = FlatUIUtils.getUIInt( "ScrollPane.Tree.arc", -1 );
|
||||
|
||||
@Override
|
||||
public Object applyStyleProperty( String key, Object value ) {
|
||||
Object oldValue = super.applyStyleProperty( key, value );
|
||||
|
||||
if( "arc".equals( key ) )
|
||||
isArcStyled = true;
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets( Component c, Insets insets ) {
|
||||
insets = super.getBorderInsets( c, insets );
|
||||
@@ -55,6 +80,21 @@ public class FlatScrollPaneBorder
|
||||
if( isCellEditor( c ) )
|
||||
return 0;
|
||||
|
||||
if( isArcStyled )
|
||||
return arc;
|
||||
|
||||
if( c instanceof JScrollPane ) {
|
||||
Component view = FlatScrollPaneUI.getView( (JScrollPane) c );
|
||||
if( listArc >= 0 && view instanceof JList )
|
||||
return listArc;
|
||||
if( tableArc >= 0 && view instanceof JTable )
|
||||
return tableArc;
|
||||
if( textComponentArc >= 0&& view instanceof JTextComponent )
|
||||
return textComponentArc;
|
||||
if( treeArc >= 0 && view instanceof JTree )
|
||||
return treeArc;
|
||||
}
|
||||
|
||||
return arc;
|
||||
}
|
||||
|
||||
|
||||
@@ -496,7 +496,7 @@ public class FlatScrollPaneUI
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Component getView( JScrollPane scrollPane ) {
|
||||
static Component getView( JScrollPane scrollPane ) {
|
||||
JViewport viewport = scrollPane.getViewport();
|
||||
return (viewport != null) ? viewport.getView() : null;
|
||||
}
|
||||
@@ -537,12 +537,14 @@ public class FlatScrollPaneUI
|
||||
@Override
|
||||
public void focusGained( FocusEvent e ) {
|
||||
// necessary to update focus border
|
||||
if( scrollpane.getBorder() instanceof FlatBorder )
|
||||
scrollpane.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost( FocusEvent e ) {
|
||||
// necessary to update focus border
|
||||
if( scrollpane.getBorder() instanceof FlatBorder )
|
||||
scrollpane.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,6 +602,10 @@ ScrollPane.background = $ScrollBar.track
|
||||
ScrollPane.fillUpperCorner = true
|
||||
ScrollPane.smoothScrolling = true
|
||||
ScrollPane.arc = 0
|
||||
#ScrollPane.List.arc = -1
|
||||
#ScrollPane.Table.arc = -1
|
||||
#ScrollPane.TextComponent.arc = -1
|
||||
#ScrollPane.Tree.arc = -1
|
||||
|
||||
|
||||
#---- SearchField ----
|
||||
|
||||
@@ -934,7 +934,7 @@ ScrollBarUI com.formdev.flatlaf.ui.FlatScrollBarUI
|
||||
|
||||
ScrollPane.arc 20
|
||||
ScrollPane.background #88ff88 HSL 120 100 77 javax.swing.plaf.ColorUIResource [UI]
|
||||
ScrollPane.border [lazy] 1,10,1,10 false com.formdev.flatlaf.ui.FlatScrollPaneBorder [UI]
|
||||
ScrollPane.border [lazy] 1,9,1,9 false com.formdev.flatlaf.ui.FlatScrollPaneBorder [UI]
|
||||
ScrollPane.fillUpperCorner true
|
||||
ScrollPane.font [active] $defaultFont [UI]
|
||||
ScrollPane.foreground #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI]
|
||||
@@ -1155,7 +1155,7 @@ Table.foreground #ff0000 HSL 0 100 50 javax.swing.plaf.Colo
|
||||
Table.gridColor #00ffff HSL 180 100 50 javax.swing.plaf.ColorUIResource [UI]
|
||||
Table.intercellSpacing 0,0 javax.swing.plaf.DimensionUIResource [UI]
|
||||
Table.rowHeight 25
|
||||
Table.scrollPaneBorder [lazy] 1,10,1,10 false com.formdev.flatlaf.ui.FlatScrollPaneBorder [UI]
|
||||
Table.scrollPaneBorder [lazy] 1,9,1,9 false com.formdev.flatlaf.ui.FlatScrollPaneBorder [UI]
|
||||
Table.selectionBackground #00aa00 HSL 120 100 33 javax.swing.plaf.ColorUIResource [UI]
|
||||
Table.selectionForeground #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI]
|
||||
Table.selectionInactiveBackground #888888 HSL 0 0 53 javax.swing.plaf.ColorUIResource [UI]
|
||||
|
||||
@@ -717,6 +717,10 @@ ScrollBar.trackHighlight
|
||||
ScrollBar.trackInsets
|
||||
ScrollBar.width
|
||||
ScrollBarUI
|
||||
ScrollPane.List.arc
|
||||
ScrollPane.Table.arc
|
||||
ScrollPane.TextComponent.arc
|
||||
ScrollPane.Tree.arc
|
||||
ScrollPane.ancestorInputMap
|
||||
ScrollPane.ancestorInputMap.RightToLeft
|
||||
ScrollPane.arc
|
||||
|
||||
Reference in New Issue
Block a user