All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jumbo.xml.XTreeCellRenderer

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.JLabel
                                   |
                                   +----jumbo.xml.XTreeCellRenderer

public class XTreeCellRenderer
extends JLabel
implements TreeCellRenderer
derived from SwingSet examples to allow customisation of the node display in the trees. Used to work nicely but has stopped. I will comment this more when it works - at present the comments are primarily from the SwingSet docs. There is a bug of some sort here and JLabel.setIcon() seems to give problems whereby the icon is not properly rendered. Therefore some of this code represents experiements

Author:
P.Murray-Rust, 1998

Variable Index

 o blueBall
 o defaultFont
 o jButton
 o jLabel
kludge; jLabel can be set to 'this' when XTreeCellRenderer is subclassed from JLable; else to jLable add'ed to JPanel
 o selected
Whether or not the item that was last configured is selected.
 o selectedBackgroundColor

Constructor Index

 o XTreeCellRenderer()

Method Index

 o getHeight()
 o getTreeCellRendererComponent(JTree, Object, boolean, boolean, boolean, int, boolean)
This is messaged from JTree whenever it needs to get the size of the component or it wants to draw it.
 o getWidth()
 o paint(Graphics)
paint is subclassed to draw the background correctly.
 o paintLabel(Graphics)

Variables

 o defaultFont
 protected static Font defaultFont
 o blueBall
 protected static ImageIcon blueBall
 o selectedBackgroundColor
 protected static final Color selectedBackgroundColor
 o selected
 protected boolean selected
Whether or not the item that was last configured is selected.

 o jLabel
 protected JLabel jLabel
kludge; jLabel can be set to 'this' when XTreeCellRenderer is subclassed from JLable; else to jLable add'ed to JPanel

 o jButton
 protected JButton jButton

Constructors

 o XTreeCellRenderer
 public XTreeCellRenderer()

Methods

 o getTreeCellRendererComponent
 public Component getTreeCellRendererComponent(JTree tree,
                                               Object value,
                                               boolean selected,
                                               boolean expanded,
                                               boolean leaf,
                                               int row,
                                               boolean hasFocus)
This is messaged from JTree whenever it needs to get the size of the component or it wants to draw it. This attempts to set the font based on value, which will be a TreeNode.

 o paint
 public void paint(Graphics g)
paint is subclassed to draw the background correctly. JLabel currently does not allow backgrounds other than white, and it will also fill behind the icon. Something that isn't desirable.

Overrides:
paint in class JComponent
 o paintLabel
 public void paintLabel(Graphics g)
 o getWidth
 public int getWidth()
Overrides:
getWidth in class JComponent
 o getHeight
 public int getHeight()
Overrides:
getHeight in class JComponent

All Packages  Class Hierarchy  This Package  Previous  Next  Index