Top Description Inners Fields Constructors Methods
javax.swing.plaf.synth

public Class SynthListUI

extends BasicListUI
implements PropertyChangeListener, SynthUI
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.synth.SynthUI, javax.swing.plaf.synth.SynthConstants, java.beans.PropertyChangeListener, java.util.EventListener
Imports
java.awt.Color, .Component, .Graphics, java.beans.PropertyChangeEvent, .PropertyChangeListener, javax.swing.DefaultListCellRenderer, .JComponent, .JList, javax.swing.border.Border, javax.swing.plaf.ComponentUI, .UIResource, javax.swing.plaf.basic.BasicListUI

Provides the Synth L&F UI delegate for javax.swing.JList.
Author
Scott Violet
Since
1.7

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
SynthListUI.SynthListCellRenderer

The DefaultListCellRenderer installed by the UI.

Field Summary

Modifier and TypeField and Description
private SynthStyle
private boolean
private boolean
Inherited from javax.swing.plaf.basic.BasicListUI:
cellHeightcellHeightscellRendererChangedcellWidthfixedCellHeightChangedfixedCellWidthChangedfocusListenerfontChangedlistlistDataListenerlistSelectionListenermodelChangedmouseInputListenerpropertyChangeListenerprototypeCellValueChangedrendererPaneselectionModelChangedupdateLayoutStateNeeded

Constructor Summary

AccessConstructor and Description
public
SynthListUI()

Constructs a SynthListUI.

Method Summary

Modifier and TypeMethod and Description
public static ComponentUI

Returns:

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

Hides javax.swing.plaf.basic.BasicListUI.createUI.

Creates a new UI object for the given component.
private int
public SynthContext
getContext(JComponent
Component requesting SynthContext.
c
)

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

Returns the Context for the specified component.
private SynthContext
getContext(JComponent c, int state)

protected void
installDefaults()

Overrides javax.swing.plaf.basic.BasicListUI.installDefaults.

Initializes list properties such as font, foreground, and background, and adds the CellRendererPane.
protected void
installListeners()

Overrides javax.swing.plaf.basic.BasicListUI.installListeners.

Creates and installs the listeners for the JList, its model, and its selectionModel.
public void
paintBorder(SynthContext
a component context
context
,
Graphics
Graphics to paint on
g
,
int
the X coordinate
x
,
int
the Y coordinate
y
,
int
width of the border
w
,
int
height of the border
h
)

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

Paints the border.
public void
propertyChange(PropertyChangeEvent
A PropertyChangeEvent object describing the event source and the property that has changed.
e
)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.
protected void
uninstallDefaults()

Overrides javax.swing.plaf.basic.BasicListUI.uninstallDefaults.

Sets the list properties that have not been explicitly overridden to null.
protected void
uninstallListeners()

Overrides javax.swing.plaf.basic.BasicListUI.uninstallListeners.

Removes the listeners from the JList, its model, and its selectionModel.
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
Inherited from javax.swing.plaf.basic.BasicListUI:
convertRowToYconvertYToRowcreateFocusListenercreateListDataListenercreateListSelectionListenercreateMouseInputListenercreatePropertyChangeListenergetBaselinegetBaselineResizeBehaviorgetCellBoundsgetPreferredSizegetRowHeightindexToLocationinstallKeyboardActionsinstallUIlocationToIndexmaybeUpdateLayoutStatepaintpaintCellselectNextIndexselectPreviousIndexuninstallKeyboardActionsuninstallUIupdateLayoutState

Field Detail

styleback to summary
private SynthStyle style
useListColorsback to summary
private boolean useListColors
useUIBorderback to summary
private boolean useUIBorder

Constructor Detail

SynthListUIback to summary
public SynthListUI()

Constructs a SynthListUI.

Method Detail

createUIback to summary
public static ComponentUI createUI(JComponent list)

Hides javax.swing.plaf.basic.BasicListUI.createUI.

Creates a new UI object for the given component.

Parameters
list:JComponent

component to create UI object for

Returns:ComponentUI

the UI object

getComponentStateback to summary
private int getComponentState(JComponent c)
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.

Parameters
c:JComponent

Component requesting SynthContext.

Returns:SynthContext

SynthContext describing component.

Annotations
@Override
getContextback to summary
private SynthContext getContext(JComponent c, int state)
installDefaultsback to summary
protected void installDefaults()

Overrides javax.swing.plaf.basic.BasicListUI.installDefaults.

Doc from javax.swing.plaf.basic.BasicListUI.installDefaults.

Initializes list properties such as font, foreground, and background, and adds the CellRendererPane. 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
installListenersback to summary
protected void installListeners()

Overrides javax.swing.plaf.basic.BasicListUI.installListeners.

Doc from javax.swing.plaf.basic.BasicListUI.installListeners.

Creates and installs the listeners for the JList, its model, and its selectionModel. This method is called at installUI() time.

Annotations
@Override
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.

Parameters
context:SynthContext

a component context

g:Graphics

Graphics to paint on

x:int

the X coordinate

y:int

the Y coordinate

w:int

width of the border

h:int

height of the border

Annotations
@Override
propertyChangeback to summary
public void propertyChange(PropertyChangeEvent e)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

Parameters
e:PropertyChangeEvent

A PropertyChangeEvent object describing the event source and the property that has changed.

Annotations
@Override
uninstallDefaultsback to summary
protected void uninstallDefaults()

Overrides javax.swing.plaf.basic.BasicListUI.uninstallDefaults.

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

Sets the list properties that have not been explicitly overridden to null. A property is considered overridden if its current value is not a UIResource.

Annotations
@Override
uninstallListenersback to summary
protected void uninstallListeners()

Overrides javax.swing.plaf.basic.BasicListUI.uninstallListeners.

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

Removes the listeners from the JList, its model, and its selectionModel. All of the listener fields, are reset to null here. This method is called at uninstallUI() time, it should be kept in sync with installListeners.

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 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
updateStyleback to summary
private void updateStyle(JComponent c)
javax.swing.plaf.synth back to summary

private Class SynthListUI.SynthListCellRenderer

extends UIResource
Class Inheritance
Annotations
@SuppressWarnings:serial

The DefaultListCellRenderer installed by the UI.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Component
getListCellRendererComponent(JList<?>
The JList we're painting.
list
,
Object
The value returned by list.getModel().getElementAt(index).
value
,
int
The cells index.
index
,
boolean
True if the specified cell was selected.
isSelected
,
boolean
True if the specified cell has the focus.
cellHasFocus
)

Overrides javax.swing.DefaultListCellRenderer.getListCellRendererComponent.

Implements javax.swing.ListCellRenderer.getListCellRendererComponent.

Return a component that has been configured to display the specified value.
public String
getName()

Overrides java.awt.Component.getName.

Gets the name of the component.
public void
paint(Graphics
the Graphics context in which to paint
g
)

Overrides javax.swing.JComponent.paint.

Invoked by Swing to draw components.
public void
setBorder(Border
the border to be rendered for this component
b
)

Overrides javax.swing.JComponent.setBorder.

Sets the border of this component.

Constructor Detail

SynthListCellRendererback to summary
private SynthListCellRenderer()

Method Detail

getListCellRendererComponentback to summary
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus)

Overrides javax.swing.DefaultListCellRenderer.getListCellRendererComponent.

Implements javax.swing.ListCellRenderer.getListCellRendererComponent.

Doc from javax.swing.ListCellRenderer.getListCellRendererComponent.

Return a component that has been configured to display the specified value. That component's paint method is then called to "render" the cell. If it is necessary to compute the dimensions of a list because the list cells do not have a fixed size, this method is called to generate a component on which getPreferredSize can be invoked.

Parameters
list:JList<?>

The JList we're painting.

value:Object

The value returned by list.getModel().getElementAt(index).

index:int

The cells index.

isSelected:boolean

True if the specified cell was selected.

cellHasFocus:boolean

True if the specified cell has the focus.

Returns:Component

A component whose paint() method will render the specified value.

Annotations
@Override
getNameback to summary
public String getName()

Overrides java.awt.Component.getName.

Doc from java.awt.Component.getName.

Gets the name of the component.

Returns:String

this component's name

Annotations
@Override
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.

Parameters
g:Graphics

the Graphics context in which to paint

Annotations
@Override
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.

Parameters
b:Border

the border to be rendered for this component

Annotations
@Override