JIDE 3.5.15

com.jidesoft.grid
Class ExpandablePanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.CellRendererPane
              extended by com.jidesoft.grid.CellRendererPaneEx
                  extended by com.jidesoft.grid.ExpandablePanel
All Implemented Interfaces:
RendererWrapper, ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
HeaderExpandablePanel

public class ExpandablePanel
extends CellRendererPaneEx

The component has a "+/-" button which can be used in TreeTable or other tables.

Since 2.9.4, we let this class to inherits Component instead of JComponent before. We have to do so to fix some painting issue. However, it may cause backward compatibility issue especially if you ever tried to cast this class to JComponent. For example, if you use Nimbus L&F, you may see a Class Cast Exception. Before Nimbus fix their issue, please override paintFocus(java.awt.Graphics) to do nothing to work around.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.CellRendererPane
CellRendererPane.AccessibleCellRendererPane
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Icon _collapsedIcon
           
protected  Color _disabledBackground
           
protected  Color _disabledForeground
           
protected  Icon _expandedIcon
           
protected  boolean _hasFocus
           
protected  boolean _isSelected
           
protected  Node _node
           
protected  JTable _table
           
static int LEFT_MARGIN
           
static int TEXT_ICON_GAP
           
static boolean VERTICAL_CENTER_ALIGNMENT
           
 
Fields inherited from class com.jidesoft.grid.CellRendererPaneEx
_actualRenderer
 
Fields inherited from class javax.swing.CellRendererPane
accessibleContext
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ExpandablePanel(JTable table, Component actualRenderer, Icon expandedIcon, Icon collapsedIcon, Color disabledBackground, Color disabledForeground)
          Creates an ExpandablePanel.
ExpandablePanel(JTable table, Icon expandedIcon, Icon collapsedIcon, Color disabledBackground, Color disabledForeground)
          Creates an ExpandablePanel.
 
Method Summary
 Dimension getMinimumSize()
           
 Dimension getPreferredSize()
           
 String getToolTipText(MouseEvent e)
          Delegates getTooltipText to actual renderer.
protected  void initComponents()
           
 boolean isExpandIconVisible(JTable table)
           
 boolean isHasFocus()
          Checks if expandable panel has focus.
 boolean isSelected()
          Checks if the expandable panel is selected.
protected  boolean isSynthIcon(Icon icon)
          Checks if the icon is a SynthIcon.
protected  boolean isSynthIconClassName(String name)
          Check if the class name is a SynthIcon class name.
 void paint(Graphics g)
          Calls the UI delegate's paint method, if the UI delegate is non-null.
protected  void paintBackground(Graphics g)
          Paints the background.
protected  void paintDecoration(Graphics g)
           
protected  void paintFocus(Graphics g)
          Paints the focus border.
protected  int paintIcon(Graphics g, int start)
          Paints icon if necessary.
 void setBackground(Color c)
           
 void setFont(Font c)
           
 void setForeground(Color c)
           
 void setHasFocus(boolean hasFocus)
          Sets the expandable panel focus attribute.
 void setNode(Node node)
          ExpandableCell is the data used by ExpandablePanel.
 void setSelected(boolean selected)
          Sets the expandable panel selected/
 
Methods inherited from class com.jidesoft.grid.CellRendererPaneEx
getActualRenderer, getBorder, isPaintBackground, paintBorder, setActualRenderer, setPaintBackground
 
Methods inherited from class javax.swing.CellRendererPane
addImpl, getAccessibleContext, invalidate, paintComponent, paintComponent, paintComponent, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TEXT_ICON_GAP

public static final int TEXT_ICON_GAP
See Also:
Constant Field Values

LEFT_MARGIN

public static final int LEFT_MARGIN
See Also:
Constant Field Values

VERTICAL_CENTER_ALIGNMENT

public static boolean VERTICAL_CENTER_ALIGNMENT

_node

protected Node _node

_table

protected JTable _table

_expandedIcon

protected Icon _expandedIcon

_collapsedIcon

protected Icon _collapsedIcon

_disabledForeground

protected Color _disabledForeground

_disabledBackground

protected Color _disabledBackground

_isSelected

protected boolean _isSelected

_hasFocus

protected boolean _hasFocus
Constructor Detail

ExpandablePanel

public ExpandablePanel(JTable table,
                       Icon expandedIcon,
                       Icon collapsedIcon,
                       Color disabledBackground,
                       Color disabledForeground)
Creates an ExpandablePanel.

Parameters:
table - the table
expandedIcon - the expanded icon
collapsedIcon - the collapsed icon
disabledBackground - the disabled background
disabledForeground - the disabled foreground

ExpandablePanel

public ExpandablePanel(JTable table,
                       Component actualRenderer,
                       Icon expandedIcon,
                       Icon collapsedIcon,
                       Color disabledBackground,
                       Color disabledForeground)
Creates an ExpandablePanel.

Parameters:
table - the table
actualRenderer - the renderer
expandedIcon - the expanded icon
collapsedIcon - the collapsed icon
disabledBackground - the disabled background
disabledForeground - the disabled foreground
Method Detail

initComponents

protected void initComponents()

setNode

public void setNode(Node node)
ExpandableCell is the data used by ExpandablePanel. ExpandableCell provides attributes such as expandable, level, name etc which is useful when painting the expandable panel. In the case of PropertyTable component, Property itself is an instance of ExpandableCell.

Parameters:
node - the node

paint

public void paint(Graphics g)
Calls the UI delegate's paint method, if the UI delegate is non-null. We pass the delegate a copy of the Graphics object to protect the rest of the paint code from irrevocable changes (for example, Graphics.translate).

If you override this in a subclass you should not make permanent changes to the passed in Graphics. For example, you should not alter the clip Rectangle or modify the transform. If you need to do these operations you may find it easier to create a new Graphics from the passed in Graphics and manipulate it. Further, if you do not invoker super's implementation you must honor the opaque property, that is if this component is opaque, you must completely fill in the background in a non-opaque color. If you do not honor the opaque property you will likely see visual artifacts.

Overrides:
paint in class CellRendererPane
Parameters:
g - the Graphics object to protect
See Also:
paint(java.awt.Graphics), ComponentUI

paintIcon

protected int paintIcon(Graphics g,
                        int start)
Paints icon if necessary.

Parameters:
g - the Graphics instance
start - the start X offset to paint the icon
Returns:
the start X offset to paint text after painting icon.
Since:
3.2.0

isSynthIcon

protected boolean isSynthIcon(Icon icon)
Checks if the icon is a SynthIcon.

Parameters:
icon - the icon
Returns:
true if the icon is a SynthIcon. Otherwise false.
Since:
3.2.0

isSynthIconClassName

protected boolean isSynthIconClassName(String name)
Check if the class name is a SynthIcon class name.

It's an interface reserved in case Sun changes the name or package of the class SynthIcon.

Parameters:
name - the class name to check
Returns:
true if it's a SynthIcon class name. Otherwise false.

paintFocus

protected void paintFocus(Graphics g)
Paints the focus border.

Parameters:
g - the Graphics instance

paintBackground

protected void paintBackground(Graphics g)
Paints the background.

Parameters:
g - the Graphics instance

paintDecoration

protected void paintDecoration(Graphics g)

isSelected

public boolean isSelected()
Checks if the expandable panel is selected.

Returns:
true if it is selected.

setSelected

public void setSelected(boolean selected)
Sets the expandable panel selected/

Parameters:
selected - the flag

isHasFocus

public boolean isHasFocus()
Checks if expandable panel has focus.

Returns:
true if it has focus.

setHasFocus

public void setHasFocus(boolean hasFocus)
Sets the expandable panel focus attribute.

Parameters:
hasFocus - the flag

getMinimumSize

public Dimension getMinimumSize()
Overrides:
getMinimumSize in class Container

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class Container

setBackground

public void setBackground(Color c)
Overrides:
setBackground in class Component

setForeground

public void setForeground(Color c)
Overrides:
setForeground in class Component

setFont

public void setFont(Font c)
Overrides:
setFont in class Container

getToolTipText

public String getToolTipText(MouseEvent e)
Delegates getTooltipText to actual renderer.

Overrides:
getToolTipText in class CellRendererPaneEx
Parameters:
e - the mouse event
Returns:
the tooltip of actual renderer

isExpandIconVisible

public boolean isExpandIconVisible(JTable table)

JIDE 3.5.15