Package com.jidesoft.swing
Class NavigationComponentHelper
java.lang.Object
com.jidesoft.swing.NavigationComponentHelper
NavigationComponentHelper
is a helper class to implement on JTree, JList and JTable (or JIDE table
subclasses) so they can be used for the navigation purpose. In order to make the component suitable for the
navigation, we want the selection effect to be easily noticeable and covers the row (instead of just one cell or one
node in the case of JTable and JTree respectively). We also want to have rollover effect the mouse is over a row.
Further more, the selection should have different color when the component is focused so that when multiple
navigation components are used, we can tell which one is active. Some L&Fs already do it by default but the most L&Fs
don't do it. This class provides some common code to make the implementation easy.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
int
Gets the rollover row that currently has rollover effect.protected abstract Rectangle
getRowBounds
(int row) Gets the bounds of the row.protected abstract int[]
protected Color
Gets the color to paint the selected rows.void
void
void
void
void
void
void
paint
(Graphics g, JComponent c) Paints the rollover row and selection rows.protected void
paintRolloverRow
(Graphics g, JComponent c, int row) Paints the rollover row.protected void
paintSelectedRow
(Graphics g, JComponent c, int row) Paints the selected row.void
protected abstract int
rowAtPoint
(Point p) void
setRolloverRow
(int rolloverRow) Sets the rollover row.void
setup
(JComponent c)
-
Constructor Details
-
NavigationComponentHelper
public NavigationComponentHelper()
-
-
Method Details
-
getRowBounds
Gets the bounds of the row.- Parameters:
row
- the bounds of the specific row.- Returns:
- the bounds of the row. Or null if there is no row at all or the specified row doesn't exist.
-
rowAtPoint
-
getSelectedRows
protected abstract int[] getSelectedRows() -
mouseMoved
-
mouseExited
-
mousePressed
-
mouseReleased
-
mouseClicked
-
mouseEntered
-
focusGained
-
focusLost
-
paint
Paints the rollover row and selection rows.- Parameters:
g
- the Graphicsc
- the component
-
paintSelectedRow
Paints the selected row. This method is called after the tree is painted. It will paint over the content of the tree. In order to not cover the content, the painting code must be semi-transparent. By default, we paint it using the selection color which can be retrieved from UIDefault "Tree.selectionBackground" but with an alpha between 70 to 100 to create a gradient effect.- Parameters:
g
- the Graphicsc
- the componentrow
- the row index
-
getSelectionColor
Gets the color to paint the selected rows.- Parameters:
c
- the component- Returns:
- the selection color.
- Since:
- 3.4.6
-
paintRolloverRow
Paints the rollover row. This method is called after the tree is painted. It will paint over the content of the tree. In order to not cover the content, the painting code must be semi-transparent. By default, we paint it using the selection color which can be retrieved from UIDefault "Tree.selectionBackground" but with an alpha between 10 to 40 to create a gradient effect.- Parameters:
g
- the Graphicsc
- the componentrow
- the row index
-
setup
-
repaintSelections
-
getRolloverRow
public int getRolloverRow()Gets the rollover row that currently has rollover effect.- Returns:
- the row that has the rollover effect.
-
setRolloverRow
public void setRolloverRow(int rolloverRow) Sets the rollover row.- Parameters:
rolloverRow
- the row to show the rollover effect.
-
getMousePosition
-