Package com.formdev.flatlaf.ui
Class FlatTableUI
- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.TableUI
-
- javax.swing.plaf.basic.BasicTableUI
-
- com.formdev.flatlaf.ui.FlatTableUI
-
- All Implemented Interfaces:
FlatStylingSupport.StyleableUI
,FlatViewportUI.ViewportPainter
public class FlatTableUI extends javax.swing.plaf.basic.BasicTableUI implements FlatStylingSupport.StyleableUI, FlatViewportUI.ViewportPainter
Provides the Flat LaF UI delegate forJTable
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
FlatTableUI.FlatBooleanRenderer
private class
FlatTableUI.FlatOutsideAlternateRowsListener
Used if table auto-resize-mode is off to repaint outside alternate rows when table width changed (column resized) or component orientation changed.private static class
FlatTableUI.FlatTablePropertyWatcher
Listener that watches for change of some table properties from application code.private class
FlatTableUI.RoundedSelectionGraphics
Because selection painting is done in the cell renderer, it would be necessary to require a FlatLaf specific renderer to implement rounded selection.private static class
FlatTableUI.StartEditingAction
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Color
cellFocusColor
protected java.awt.Insets
cellMargins
private javax.swing.event.TableColumnModelListener
columnSelectionListener
protected java.awt.Dimension
intercellSpacing
private javax.swing.table.TableCellRenderer
oldBooleanRenderer
private java.awt.Dimension
oldIntercellSpacing
private boolean
oldShowHorizontalLines
private boolean
oldShowVerticalLines
private java.util.Map<java.lang.String,java.lang.Object>
oldStyleValues
private java.awt.event.ComponentListener
outsideAlternateRowsListener
private java.beans.PropertyChangeListener
propertyChangeListener
private javax.swing.event.ListSelectionListener
rowSelectionListener
protected int
selectionArc
protected java.awt.Color
selectionBackground
protected java.awt.Color
selectionForeground
protected java.awt.Color
selectionInactiveBackground
protected java.awt.Color
selectionInactiveForeground
protected java.awt.Insets
selectionInsets
protected java.lang.Boolean
showCellFocusIndicator
protected boolean
showHorizontalLines
protected boolean
showTrailingVerticalLine
protected boolean
showVerticalLines
-
Constructor Summary
Constructors Constructor Description FlatTableUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyStyle(java.lang.Object style)
protected java.lang.Object
applyStyleProperty(java.lang.String key, java.lang.Object value)
protected java.awt.event.FocusListener
createFocusListener()
static javax.swing.plaf.ComponentUI
createUI(javax.swing.JComponent c)
java.util.Map<java.lang.String,java.lang.Class<?>>
getStyleableInfos(javax.swing.JComponent c)
java.lang.Object
getStyleableValue(javax.swing.JComponent c, java.lang.String key)
protected boolean
hideLastVerticalLine()
protected void
installDefaults()
protected void
installKeyboardActions()
protected void
installListeners()
private void
installRepaintRoundedSelectionListeners()
protected void
installStyle()
void
installUI(javax.swing.JComponent c)
void
paint(java.awt.Graphics g, javax.swing.JComponent c)
protected void
paintAlternateRowBackground(java.awt.Graphics g, int row, int column, int x, int y, int width, int height)
Paints (rounded) alternate row background.protected void
paintCellSelection(java.awt.Graphics g, int row, int column, int x, int y, int width, int height)
Paints (rounded) cell selection.static void
paintCellSelection(javax.swing.JTable table, java.awt.Graphics g, int row, int column, int x, int y, int width, int height)
Paints a cell selection at the given coordinates.void
paintViewport(java.awt.Graphics g, javax.swing.JComponent c, javax.swing.JViewport viewport)
private void
repaintRoundedColumnSelection(javax.swing.event.ListSelectionEvent e)
private void
repaintRoundedRowSelection(javax.swing.event.ListSelectionEvent e)
private void
toggleSelectionColors()
Toggle selection colors from focused to inactive and vice versa.protected void
uninstallDefaults()
protected void
uninstallListeners()
-
Methods inherited from class javax.swing.plaf.basic.BasicTableUI
createKeyListener, createMouseInputListener, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, uninstallKeyboardActions, uninstallUI
-
-
-
-
Field Detail
-
showHorizontalLines
protected boolean showHorizontalLines
-
showVerticalLines
protected boolean showVerticalLines
-
showTrailingVerticalLine
protected boolean showTrailingVerticalLine
- Since:
- 1.6
-
intercellSpacing
protected java.awt.Dimension intercellSpacing
-
selectionBackground
protected java.awt.Color selectionBackground
-
selectionForeground
protected java.awt.Color selectionForeground
-
selectionInactiveBackground
protected java.awt.Color selectionInactiveBackground
-
selectionInactiveForeground
protected java.awt.Color selectionInactiveForeground
-
selectionInsets
protected java.awt.Insets selectionInsets
- Since:
- 3.5
-
selectionArc
protected int selectionArc
- Since:
- 3.5
-
cellMargins
protected java.awt.Insets cellMargins
- Since:
- 2
-
cellFocusColor
protected java.awt.Color cellFocusColor
- Since:
- 2
-
showCellFocusIndicator
protected java.lang.Boolean showCellFocusIndicator
- Since:
- 2
-
oldShowHorizontalLines
private boolean oldShowHorizontalLines
-
oldShowVerticalLines
private boolean oldShowVerticalLines
-
oldIntercellSpacing
private java.awt.Dimension oldIntercellSpacing
-
oldBooleanRenderer
private javax.swing.table.TableCellRenderer oldBooleanRenderer
-
propertyChangeListener
private java.beans.PropertyChangeListener propertyChangeListener
-
outsideAlternateRowsListener
private java.awt.event.ComponentListener outsideAlternateRowsListener
-
rowSelectionListener
private javax.swing.event.ListSelectionListener rowSelectionListener
-
columnSelectionListener
private javax.swing.event.TableColumnModelListener columnSelectionListener
-
oldStyleValues
private java.util.Map<java.lang.String,java.lang.Object> oldStyleValues
-
-
Method Detail
-
createUI
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
-
installUI
public void installUI(javax.swing.JComponent c)
- Overrides:
installUI
in classjavax.swing.plaf.basic.BasicTableUI
-
installDefaults
protected void installDefaults()
- Overrides:
installDefaults
in classjavax.swing.plaf.basic.BasicTableUI
-
uninstallDefaults
protected void uninstallDefaults()
- Overrides:
uninstallDefaults
in classjavax.swing.plaf.basic.BasicTableUI
-
installListeners
protected void installListeners()
- Overrides:
installListeners
in classjavax.swing.plaf.basic.BasicTableUI
-
uninstallListeners
protected void uninstallListeners()
- Overrides:
uninstallListeners
in classjavax.swing.plaf.basic.BasicTableUI
-
createFocusListener
protected java.awt.event.FocusListener createFocusListener()
- Overrides:
createFocusListener
in classjavax.swing.plaf.basic.BasicTableUI
-
installKeyboardActions
protected void installKeyboardActions()
- Overrides:
installKeyboardActions
in classjavax.swing.plaf.basic.BasicTableUI
-
installStyle
protected void installStyle()
- Since:
- 2
-
applyStyle
protected void applyStyle(java.lang.Object style)
- Since:
- 2
-
applyStyleProperty
protected java.lang.Object applyStyleProperty(java.lang.String key, java.lang.Object value)
- Since:
- 2
-
getStyleableInfos
public java.util.Map<java.lang.String,java.lang.Class<?>> getStyleableInfos(javax.swing.JComponent c)
- Specified by:
getStyleableInfos
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2
-
getStyleableValue
public java.lang.Object getStyleableValue(javax.swing.JComponent c, java.lang.String key)
- Specified by:
getStyleableValue
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2.5
-
toggleSelectionColors
private void toggleSelectionColors()
Toggle selection colors from focused to inactive and vice versa. This is not an optimal solution but much easier than rewriting the whole paint methods. Using a LaF specific renderer was avoided because often a custom renderer is already used in applications. Then either the inactive colors are not used, or the application has to be changed to extend a FlatLaf renderer.
-
paint
public void paint(java.awt.Graphics g, javax.swing.JComponent c)
- Overrides:
paint
in classjavax.swing.plaf.basic.BasicTableUI
-
hideLastVerticalLine
protected boolean hideLastVerticalLine()
-
paintViewport
public void paintViewport(java.awt.Graphics g, javax.swing.JComponent c, javax.swing.JViewport viewport)
- Specified by:
paintViewport
in interfaceFlatViewportUI.ViewportPainter
- Since:
- 2.3
-
paintAlternateRowBackground
protected void paintAlternateRowBackground(java.awt.Graphics g, int row, int column, int x, int y, int width, int height)
Paints (rounded) alternate row background. SupportsselectionArc
andselectionInsets
.Note: This method is only invoked if either selection arc is greater than zero or if selection insets are not empty.
- Since:
- 3.5
-
paintCellSelection
protected void paintCellSelection(java.awt.Graphics g, int row, int column, int x, int y, int width, int height)
Paints (rounded) cell selection. SupportsselectionArc
andselectionInsets
.Note: This method is only invoked if either selection arc is greater than zero or if selection insets are not empty.
- Since:
- 3.5
-
paintCellSelection
public static void paintCellSelection(javax.swing.JTable table, java.awt.Graphics g, int row, int column, int x, int y, int width, int height)
Paints a cell selection at the given coordinates. The selection color must be set on the graphics context.This method is intended for use in custom cell renderers to support
selectionArc
andselectionInsets
.- Since:
- 3.5
-
installRepaintRoundedSelectionListeners
private void installRepaintRoundedSelectionListeners()
-
repaintRoundedRowSelection
private void repaintRoundedRowSelection(javax.swing.event.ListSelectionEvent e)
-
repaintRoundedColumnSelection
private void repaintRoundedColumnSelection(javax.swing.event.ListSelectionEvent e)
-
-