APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.synth

public Class SynthTableUI

extends BasicTableUI
implements SynthUI, PropertyChangeListener
Class Inheritance
All Implemented Interfaces
java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.plaf.synth.SynthUI, javax.swing.plaf.synth.SynthConstants
Imports
java.awt.Color, .Component, .Dimension, .Graphics, .Point, .Rectangle, java.beans.PropertyChangeEvent, .PropertyChangeListener, java.text.DateFormat, .Format, .NumberFormat, java.util.Date, javax.swing.Icon, .ImageIcon, .JCheckBox, .JComponent, .JLabel, .JTable, .LookAndFeel, javax.swing.border.Border, javax.swing.plaf.ColorUIResource, .ComponentUI, .UIResource, javax.swing.plaf.basic.BasicTableUI, javax.swing.table.DefaultTableCellRenderer, .JTableHeader, .TableCellRenderer, .TableColumn, .TableColumnModel

Provides the Synth L&F UI delegate for javax.swing.JTable.
Author
Philip Milne
Since
1.7

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SynthTableUI.SynthBooleanTableCellRenderer

The renderer installed by the UI to render the boolean data.

private class
SynthTableUI.SynthTableCellRenderer

The DefaultTableCellRenderer installed by the UI.

Field Summary

Modifier and TypeField and Description
private Color
private TableCellRenderer
private TableCellRenderer
private TableCellRenderer
private TableCellRenderer
private TableCellRenderer
private TableCellRenderer
private TableCellRenderer
private TableCellRenderer
private boolean
private boolean
private SynthStyle
private boolean
private boolean
Inherited from javax.swing.plaf.basic.BasicTableUI:
focusListenerkeyListenermouseInputListenerrendererPanetable

Constructor Summary

AccessConstructor and Description
public
SynthTableUI()

Constructs a SynthTableUI.

Method Summary

Modifier and TypeMethod and Description
public static ComponentUI

Returns:

the UI object
createUI
(JComponent
component to create UI object for
c
)

Hides javax.swing.plaf.basic.BasicTableUI.createUI.

Creates a new UI object for the given component.

private Rectangle
public SynthContext
getContext(JComponent c)

Implements javax.swing.plaf.synth.SynthUI.getContext.

Returns the Context for the specified component.

private SynthContext
getContext(JComponent c, int state)

private Rectangle
private Rectangle
protected void
installDefaults()

Overrides javax.swing.plaf.basic.BasicTableUI.installDefaults.

Initializes JTable properties, such as font, foreground, and background.

protected void
installListeners()

Overrides javax.swing.plaf.basic.BasicTableUI.installListeners.

Attaches listeners to the JTable.

private TableCellRenderer
public void
paint(Graphics
the Graphics object used for painting
g
,
JComponent
the component being painted
c
)

Overrides javax.swing.plaf.basic.BasicTableUI.paint.

Paints the specified component according to the Look and Feel.

protected void
paint(SynthContext
context for the component being painted
context
,
Graphics
the Graphics object used for painting
g
)

Paints the specified component.

public void
paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)

Implements javax.swing.plaf.synth.SynthUI.paintBorder.

Paints the border.

private void
paintCell(SynthContext context, Graphics g, Rectangle cellRect, int row, int column)

private void
paintCells(SynthContext context, Graphics g, int rMin, int rMax, int cMin, int cMax)

private void
paintDraggedArea(SynthContext context, Graphics g, int rMin, int rMax, TableColumn draggedColumn, int distance)

private void
private void
paintGrid(SynthContext context, Graphics g, int rMin, int rMax, int cMin, int cMax)

public void
propertyChange(PropertyChangeEvent event)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

protected void
protected void
public void
update(Graphics
the Graphics object used for painting
g
,
JComponent
the component being painted
c
)

Overrides javax.swing.plaf.ComponentUI.update.

Notifies this UI delegate to repaint the specified component.

private void
private int
Inherited from javax.swing.plaf.basic.BasicTableUI:
createFocusListenercreateKeyListenercreateMouseInputListenergetBaselinegetBaselineResizeBehaviorgetMaximumSizegetMinimumSizegetPreferredSizeinstallKeyboardActionsinstallUIuninstallKeyboardActionsuninstallUI

Field Detail

alternateColorback to summary
private Color alternateColor
booleanRendererback to summary
private TableCellRenderer booleanRenderer
dateRendererback to summary
private TableCellRenderer dateRenderer
doubleRenderback to summary
private TableCellRenderer doubleRender
floatRendererback to summary
private TableCellRenderer floatRenderer
iconRendererback to summary
private TableCellRenderer iconRenderer
imageIconRendererback to summary
private TableCellRenderer imageIconRenderer
numberRendererback to summary
private TableCellRenderer numberRenderer
objectRendererback to summary
private TableCellRenderer objectRenderer
showHorizLinesback to summary
private boolean showHorizLines
showVertLinesback to summary
private boolean showVertLines
styleback to summary
private SynthStyle style
useTableColorsback to summary
private boolean useTableColors
useUIBorderback to summary
private boolean useUIBorder

Constructor Detail

SynthTableUIback to summary
public SynthTableUI()

Constructs a SynthTableUI.

Method Detail

createUIback to summary
public static ComponentUI createUI(JComponent c)

Hides javax.swing.plaf.basic.BasicTableUI.createUI.

Creates a new UI object for the given component.

Parameters
c:JComponent

component to create UI object for

Returns:ComponentUI

the UI object

extendRectback to summary
private Rectangle extendRect(Rectangle rect, boolean horizontal)

Hides javax.swing.plaf.basic.BasicTableUI.extendRect.

getContextback to summary
public SynthContext getContext(JComponent c)

Implements javax.swing.plaf.synth.SynthUI.getContext.

Doc from javax.swing.plaf.synth.SynthUI.getContext.

Returns the Context for the specified component.

Annotations
@Override
getContextback to summary
private SynthContext getContext(JComponent c, int state)
getHDropLineRectback to summary
private Rectangle getHDropLineRect(JTable.DropLocation loc)

Hides javax.swing.plaf.basic.BasicTableUI.getHDropLineRect.

getVDropLineRectback to summary
private Rectangle getVDropLineRect(JTable.DropLocation loc)

Hides javax.swing.plaf.basic.BasicTableUI.getVDropLineRect.

installDefaultsback to summary
protected void installDefaults()

Overrides javax.swing.plaf.basic.BasicTableUI.installDefaults.

Initializes JTable properties, such as font, foreground, and background. The font, foreground, and background properties are only set if their current value is either null or a UIResource, other properties are set if the current value is null.

Annotations
@Override
See Also
installUI
installListenersback to summary
protected void installListeners()

Overrides javax.swing.plaf.basic.BasicTableUI.installListeners.

Attaches listeners to the JTable.

Annotations
@Override
installRendererIfPossibleback to summary
private TableCellRenderer installRendererIfPossible(Class<?> objectClass, TableCellRenderer renderer)
paintback to summary
public void paint(Graphics g, JComponent c)

Overrides javax.swing.plaf.basic.BasicTableUI.paint.

Paints the specified component according to the Look and Feel.

This method is not used by Synth Look and Feel. Painting is handled by the paint(SynthContext, Graphics) method.

Parameters
g:Graphics

the Graphics object used for painting

c:JComponent

the component being painted

Annotations
@Override
See Also
paint(SynthContext, Graphics)
paintback to summary
protected void paint(SynthContext context, Graphics g)

Paints the specified component.

Parameters
context:SynthContext

context for the component being painted

g:Graphics

the Graphics object used for painting

See Also
update(Graphics, JComponent)
paintBorderback to summary
public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)

Implements javax.swing.plaf.synth.SynthUI.paintBorder.

Doc from javax.swing.plaf.synth.SynthUI.paintBorder.

Paints the border.

Annotations
@Override
paintCellback to summary
private void paintCell(SynthContext context, Graphics g, Rectangle cellRect, int row, int column)
paintCellsback to summary
private void paintCells(SynthContext context, Graphics g, int rMin, int rMax, int cMin, int cMax)
paintDraggedAreaback to summary
private void paintDraggedArea(SynthContext context, Graphics g, int rMin, int rMax, TableColumn draggedColumn, int distance)
paintDropLinesback to summary
private void paintDropLines(SynthContext context, Graphics g)
paintGridback to summary
private void paintGrid(SynthContext context, Graphics g, int rMin, int rMax, int cMin, int cMax)
propertyChangeback to summary
public void propertyChange(PropertyChangeEvent event)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

Annotations
@Override
uninstallDefaultsback to summary
protected void uninstallDefaults()

Overrides javax.swing.plaf.basic.BasicTableUI.uninstallDefaults.

Doc from javax.swing.plaf.basic.BasicTableUI.uninstallDefaults.

Uninstalls default properties.

Annotations
@Override
uninstallListenersback to summary
protected void uninstallListeners()

Overrides javax.swing.plaf.basic.BasicTableUI.uninstallListeners.

Doc from javax.swing.plaf.basic.BasicTableUI.uninstallListeners.

Unregisters listeners.

Annotations
@Override
updateback to summary
public void update(Graphics g, JComponent c)

Overrides javax.swing.plaf.ComponentUI.update.

Notifies this UI delegate to repaint the specified component. This method paints the component background, then calls the paint(SynthContext, Graphics) method.

In general, this method does not need to be overridden by subclasses. All Look and Feel rendering code should reside in the paint method.

Parameters
g:Graphics

the Graphics object used for painting

c:JComponent

the component being painted

Annotations
@Override
See Also
paint(SynthContext, Graphics)
updateStyleback to summary
private void updateStyle(JTable c)
viewIndexForColumnback to summary
private int viewIndexForColumn(TableColumn aColumn)

Hides javax.swing.plaf.basic.BasicTableUI.viewIndexForColumn.

javax.swing.plaf.synth back to summary

private Class SynthTableUI.SynthBooleanTableCellRenderer

extends JCheckBox
implements TableCellRenderer
Class Inheritance
All Implemented Interfaces
javax.swing.table.TableCellRenderer
Annotations
@SuppressWarnings:serial

The renderer installed by the UI to render the boolean data.

Field Summary

Modifier and TypeField and Description
private boolean
Inherited from javax.swing.JCheckBox:
BORDER_PAINTED_FLAT_CHANGED_PROPERTY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Component
getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)

Implements javax.swing.table.TableCellRenderer.getTableCellRendererComponent.

Returns the component used for drawing the cell.

public boolean
isOpaque()

Overrides javax.swing.JComponent.isOpaque.

Returns true if this component is completely opaque.

private Color
Inherited from javax.swing.JCheckBox:
getAccessibleContextgetUIClassIDisBorderPaintedFlatparamStringsetBorderPaintedFlatupdateUI

Field Detail

isRowSelectedback to summary
private boolean isRowSelected

Constructor Detail

SynthBooleanTableCellRendererback to summary
public SynthBooleanTableCellRenderer()

Method Detail

getTableCellRendererComponentback to summary
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)

Implements javax.swing.table.TableCellRenderer.getTableCellRendererComponent.

Doc from javax.swing.table.TableCellRenderer.getTableCellRendererComponent.

Returns the component used for drawing the cell. This method is used to configure the renderer appropriately before drawing.

The TableCellRenderer is also responsible for rendering the the cell representing the table's current DnD drop location if it has one. If this renderer cares about rendering the DnD drop location, it should query the table directly to see if the given row and column represent the drop location:

    JTable.DropLocation dropLocation = table.getDropLocation();
    if (dropLocation != null
            && !dropLocation.isInsertRow()
            && !dropLocation.isInsertColumn()
            && dropLocation.getRow() == row
            && dropLocation.getColumn() == column) {

        // this cell represents the current drop location
        // so render it specially, perhaps with a different color
    }

During a printing operation, this method will be called with isSelected and hasFocus values of false to prevent selection and focus from appearing in the printed output. To do other customization based on whether or not the table is being printed, check the return value from javax.swing.JComponent#isPaintingForPrint().

isOpaqueback to summary
public boolean isOpaque()

Overrides javax.swing.JComponent.isOpaque.

Doc from javax.swing.JComponent.isOpaque.

Returns true if this component is completely opaque.

An opaque component paints every pixel within its rectangular bounds. A non-opaque component paints only a subset of its pixels or none at all, allowing the pixels underneath it to "show through". Therefore, a component that does not fully paint its pixels provides a degree of transparency.

Subclasses that guarantee to always completely paint their contents should override this method and return true.

unwrapback to summary
private Color unwrap(Color c)
javax.swing.plaf.synth back to summary

private Class SynthTableUI.SynthTableCellRenderer

extends DefaultTableCellRenderer
Class Inheritance
Annotations
@SuppressWarnings:serial

The DefaultTableCellRenderer installed by the UI.

Field Summary

Modifier and TypeField and Description
private Object
private Object
private boolean
Inherited from javax.swing.table.DefaultTableCellRenderer:
noFocusBorder

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
configureValue(Object value, Class<?> columnClass)

public String
getName()

Overrides java.awt.Component.getName.

Gets the name of the component.

public Component
getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)

Overrides javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent.

Implements javax.swing.table.TableCellRenderer.getTableCellRendererComponent.

Returns the default table cell renderer.

public boolean
isOpaque()

Overrides javax.swing.table.DefaultTableCellRenderer.isOpaque.

Overridden for performance reasons.

public void
paint(Graphics g)

Overrides javax.swing.JComponent.paint.

Invoked by Swing to draw components.

public void
setBorder(Border b)

Overrides javax.swing.JComponent.setBorder.

Sets the border of this component.

public void
setOpaque(boolean isOpaque)

Overrides javax.swing.JComponent.setOpaque.

If true the component paints every pixel within its bounds.

Inherited from javax.swing.table.DefaultTableCellRenderer:
firePropertyChangefirePropertyChangeinvalidaterepaintrepaintrepaintrevalidatesetBackgroundsetForegroundsetValueupdateUIvalidate

Field Detail

dateFormatback to summary
private Object dateFormat
numberFormatback to summary
private Object numberFormat
opaqueback to summary
private boolean opaque

Constructor Detail

SynthTableCellRendererback to summary
private SynthTableCellRenderer()

Method Detail

configureValueback to summary
private void configureValue(Object value, Class<?> columnClass)
getNameback to summary
public String getName()

Overrides java.awt.Component.getName.

Doc from java.awt.Component.getName.

Gets the name of the component.

getTableCellRendererComponentback to summary
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)

Overrides javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent.

Implements javax.swing.table.TableCellRenderer.getTableCellRendererComponent.

Doc from javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent.

Returns the default table cell renderer.

During a printing operation, this method will be called with isSelected and hasFocus values of false to prevent selection and focus from appearing in the printed output. To do other customization based on whether or not the table is being printed, check the return value from javax.swing.JComponent#isPaintingForPrint().

isOpaqueback to summary
public boolean isOpaque()

Overrides javax.swing.table.DefaultTableCellRenderer.isOpaque.

Doc from javax.swing.table.DefaultTableCellRenderer.isOpaque.

Overridden for performance reasons. See the Implementation Note for more information.

paintback to summary
public void paint(Graphics g)

Overrides javax.swing.JComponent.paint.

Doc from javax.swing.JComponent.paint.

Invoked by Swing to draw components. Applications should not invoke paint directly, but should instead use the repaint method to schedule the component for redrawing.

This method actually delegates the work of painting to three protected methods: paintComponent, paintBorder, and paintChildren. They're called in the order listed to ensure that children appear on top of component itself. Generally speaking, the component and its children should not paint in the insets area allocated to the border. Subclasses can just override this method, as always. A subclass that just wants to specialize the UI (look and feel) delegate's paint method should just override paintComponent.

setBorderback to summary
public void setBorder(Border b)

Overrides javax.swing.JComponent.setBorder.

Doc from javax.swing.JComponent.setBorder.

Sets the border of this component. The Border object is responsible for defining the insets for the component (overriding any insets set directly on the component) and for optionally rendering any border decorations within the bounds of those insets. Borders should be used (rather than insets) for creating both decorative and non-decorative (such as margins and padding) regions for a swing component. Compound borders can be used to nest multiple borders within a single component.

Although technically you can set the border on any object that inherits from JComponent, the look and feel implementation of many standard Swing components doesn't work well with user-set borders. In general, when you want to set a border on a standard Swing component other than JPanel or JLabel, we recommend that you put the component in a JPanel and set the border on the JPanel.

This is a bound property.

setOpaqueback to summary
public void setOpaque(boolean isOpaque)

Overrides javax.swing.JComponent.setOpaque.

Doc from javax.swing.JComponent.setOpaque.

If true the component paints every pixel within its bounds. Otherwise, the component may not paint some or all of its pixels, allowing the underlying pixels to show through.

The default value of this property is false for JComponent. However, the default value for this property on most standard JComponent subclasses (such as JButton and JTree) is look-and-feel dependent.