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 classFlatTableUI.FlatBooleanRendererprivate classFlatTableUI.FlatOutsideAlternateRowsListenerUsed if table auto-resize-mode is off to repaint outside alternate rows when table width changed (column resized) or component orientation changed.private static classFlatTableUI.FlatTablePropertyWatcherListener that watches for change of some table properties from application code.private classFlatTableUI.RoundedSelectionGraphicsBecause selection painting is done in the cell renderer, it would be necessary to require a FlatLaf specific renderer to implement rounded selection.private static classFlatTableUI.StartEditingAction
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.ColorcellFocusColorprotected java.awt.InsetscellMarginsprivate javax.swing.event.TableColumnModelListenercolumnSelectionListenerprotected java.awt.DimensionintercellSpacingprivate javax.swing.table.TableCellRendereroldBooleanRendererprivate java.awt.DimensionoldIntercellSpacingprivate booleanoldShowHorizontalLinesprivate booleanoldShowVerticalLinesprivate java.util.Map<java.lang.String,java.lang.Object>oldStyleValuesprivate java.awt.event.ComponentListeneroutsideAlternateRowsListenerprivate java.beans.PropertyChangeListenerpropertyChangeListenerprivate javax.swing.event.ListSelectionListenerrowSelectionListenerprotected intselectionArcprotected java.awt.ColorselectionBackgroundprotected java.awt.ColorselectionForegroundprotected java.awt.ColorselectionInactiveBackgroundprotected java.awt.ColorselectionInactiveForegroundprotected java.awt.InsetsselectionInsetsprotected java.lang.BooleanshowCellFocusIndicatorprotected booleanshowHorizontalLinesprotected booleanshowTrailingVerticalLineprotected booleanshowVerticalLines
-
Constructor Summary
Constructors Constructor Description FlatTableUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyStyle(java.lang.Object style)protected java.lang.ObjectapplyStyleProperty(java.lang.String key, java.lang.Object value)protected java.awt.event.FocusListenercreateFocusListener()static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent c)java.util.Map<java.lang.String,java.lang.Class<?>>getStyleableInfos(javax.swing.JComponent c)java.lang.ObjectgetStyleableValue(javax.swing.JComponent c, java.lang.String key)protected booleanhideLastVerticalLine()protected voidinstallDefaults()protected voidinstallKeyboardActions()protected voidinstallListeners()private voidinstallRepaintRoundedSelectionListeners()protected voidinstallStyle()voidinstallUI(javax.swing.JComponent c)voidpaint(java.awt.Graphics g, javax.swing.JComponent c)protected voidpaintAlternateRowBackground(java.awt.Graphics g, int row, int column, int x, int y, int width, int height)Paints (rounded) alternate row background.protected voidpaintCellSelection(java.awt.Graphics g, int row, int column, int x, int y, int width, int height)Paints (rounded) cell selection.static voidpaintCellSelection(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.voidpaintViewport(java.awt.Graphics g, javax.swing.JComponent c, javax.swing.JViewport viewport)private voidrepaintRoundedColumnSelection(javax.swing.event.ListSelectionEvent e)private voidrepaintRoundedRowSelection(javax.swing.event.ListSelectionEvent e)private voidtoggleSelectionColors()Toggle selection colors from focused to inactive and vice versa.protected voiduninstallDefaults()protected voiduninstallListeners()-
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:
installUIin classjavax.swing.plaf.basic.BasicTableUI
-
installDefaults
protected void installDefaults()
- Overrides:
installDefaultsin classjavax.swing.plaf.basic.BasicTableUI
-
uninstallDefaults
protected void uninstallDefaults()
- Overrides:
uninstallDefaultsin classjavax.swing.plaf.basic.BasicTableUI
-
installListeners
protected void installListeners()
- Overrides:
installListenersin classjavax.swing.plaf.basic.BasicTableUI
-
uninstallListeners
protected void uninstallListeners()
- Overrides:
uninstallListenersin classjavax.swing.plaf.basic.BasicTableUI
-
createFocusListener
protected java.awt.event.FocusListener createFocusListener()
- Overrides:
createFocusListenerin classjavax.swing.plaf.basic.BasicTableUI
-
installKeyboardActions
protected void installKeyboardActions()
- Overrides:
installKeyboardActionsin 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:
getStyleableInfosin interfaceFlatStylingSupport.StyleableUI- Since:
- 2
-
getStyleableValue
public java.lang.Object getStyleableValue(javax.swing.JComponent c, java.lang.String key)- Specified by:
getStyleableValuein 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:
paintin 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:
paintViewportin 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. SupportsselectionArcandselectionInsets.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. SupportsselectionArcandselectionInsets.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
selectionArcandselectionInsets.- 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)
-
-