|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.guigarage.jgrid.JGrid
public class JGrid
A Component that displays a list of Elements in a grid. The Elements stored
is a separate model, ListModel. So you can use a JList
parallel to to the JGrid
JList,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| 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 |
|---|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.SwingConstants |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
JGrid()
Constructs a JGrid with a DefaultListModel. |
|
JGrid(ListModel model)
Constructs a JGrid that displays elements from the specified,
non-null, model. |
|
| Method Summary | |
|---|---|
void |
addListDataListener(ListDataListener l)
Adds a listener to the JGrid, to be notified each time a change to the data occurs. |
void |
addListSelectionListener(ListSelectionListener l)
Adds a listener to the JGrid, to be notified each time a change to the selection occurs. |
void |
addRendererMapping(Class<?> cls,
GridCellRenderer renderer)
Adds a renderer to the handler. |
protected ListSelectionModel |
createDefaultSelectionModel()
Returns an default instance of ListSelectionModel; called during
construction to initialize the grids selectionModel. |
int |
getCellAt(Point point)
Returns the index of the cell at the given point. |
Color |
getCellBackground()
Getter for the default cellbackground. |
Rectangle |
getCellBounds(int index)
Returns the bounds inside the grid for the cell at index |
GridCellRenderer |
getCellRenderer(int index)
Returns the for a specific cell |
GridCellRendererManager |
getCellRendererManager()
Return the GridCellRendererManager of the JGrid |
int |
getColumnForIndex(int index)
Returns the index of the column where modelIndex is in |
GridCellRenderer |
getDefaultRenderer()
Returns the defaultRenderer. |
int |
getFixedCellDimension()
Returns the Dimension of a cell. |
int |
getHorizontalAlignment()
Getter for the horizontal alignment. |
int |
getHorizonztalMargin()
Returns the horizonztalMargin. |
int |
getIndexAt(int row,
int column)
Returns the model-index of the cell at row /
column |
int |
getLeadSelectionIndex()
Returns the leadSelectionIndex from the ListSelectionModel |
ListModel |
getModel()
Return the Model of the JGrid |
Dimension |
getPreferredScrollableViewportSize()
|
int |
getRowForIndex(int index)
Returns the index of the row where modelIndex is in |
int |
getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction)
|
boolean |
getScrollableTracksViewportHeight()
|
boolean |
getScrollableTracksViewportWidth()
|
int |
getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)
|
int |
getSelectedIndex()
Returns the selected Index from the ListSelectionModel |
Color |
getSelectionBackground()
Getter for the selectionBackground. |
Color |
getSelectionBorderColor()
Getter for the selectionBorderColor. |
Color |
getSelectionForeground()
Getter for the selectionForeground. |
ListSelectionModel |
getSelectionModel()
Returns the ListSelectionModel |
String |
getToolTipText(MouseEvent event)
|
GridUI |
getUI()
Returns the UI-Class for this JComponent. |
String |
getUIClassID()
|
int |
getVerticalMargin()
Returns the verticalMargin. |
void |
removeListDataListener(ListDataListener l)
Removes a listener from the JGrid. |
void |
removeListSelectionListener(ListSelectionListener l)
Removes a listener from the JGrid. |
protected void |
revalidateAndRepaint()
Calls revalidate() and repaint() |
void |
setCellBackground(Color cellBackground)
Setter for the default cellbackground. |
void |
setCellRendererManager(GridCellRendererManager cellRendererManager)
Sets the GridCellRendererManager of the JGrid |
void |
setDefaultRenderer(GridCellRenderer defaultRenderer)
Set the defaultRenderer. |
void |
setFixedCellDimension(int dimension)
Sets the rendering dimension for all elements in the grid. |
void |
setHorizontalAlignment(int alignment)
Setter for the horizontal alignment. |
void |
setHorizonztalMargin(int horizonztalMargin)
Sets the horizonztal margin between all elements in the grid. |
void |
setModel(ListModel model)
Sets the model that represents values of the JGrid |
void |
setSelectedIndex(int index)
Sets the index of the selected cell |
void |
setSelectionBackground(Color selectionBackground)
Setter for the selectionBackground. |
void |
setSelectionBorderColor(Color selectionBorderColor)
Setter for the selectionBorderColor. |
void |
setSelectionForeground(Color selectionForeground)
Setter for the selectionForeground. |
void |
setSelectionModel(ListSelectionModel selectionModel)
Sets the ListSelectionModel of the JGrid |
void |
setUI(BasicGridUI ui)
Setter for the UIClass |
void |
setVerticalMargin(int verticalMargin)
Sets the vertical margin between all elements in the grid. |
void |
updateUI()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JGrid()
JGrid with a DefaultListModel.
model - the model for the grid
IllegalArgumentException - if the model is null
public JGrid(ListModel model)
throws IllegalArgumentException
JGrid that displays elements from the specified,
non-null, model. All JGrid constructors must delegate to
this one.
model - the model for the grid
IllegalArgumentException - if the model is null| Method Detail |
|---|
public void addListSelectionListener(ListSelectionListener l)
ListSelectionProxy. Every
time the underlying ListSelectionModel changes all listeners will
be registered to the new model and deregistered from the old one. For
adding listeneres to the model-scope (direct to the model) use
ListSelectionListener.addListSelectionListener
listener - the ListSelectionListener to addremoveListSelectionListener(javax.swing.event.ListSelectionListener)public void removeListSelectionListener(ListSelectionListener l)
listener - the ListSelectionListener to removeaddListSelectionListener(javax.swing.event.ListSelectionListener)public void addListDataListener(ListDataListener l)
ListDataProxy. Every
time the underlying ListModel changes all listeners will
be registered to the new model and deregistered from the old one. For
adding listeneres to the model-scope (direct to the model) use
ListModel.addListDataListener
listener - the ListSelectionListener to addremoveListDataListener(javax.swing.event.ListDataListener)public void removeListDataListener(ListDataListener l)
listener - the ListDataListener to removeaddListDataListener(javax.swing.event.ListDataListener)public void setSelectionModel(ListSelectionModel selectionModel)
ListSelectionModel of the JGrid
selectionModel - the new ListSelectionModel
IllegalArgumentException - if the model is nullgetSelectionModel()
public void setCellRendererManager(GridCellRendererManager cellRendererManager)
throws IllegalArgumentException
GridCellRendererManager of the JGrid
cellRendererManager - the new GridCellRendererManager
IllegalArgumentException - if the cellRendererManager is nullGridCellRendererManager,
getCellRendererManager()public GridCellRendererManager getCellRendererManager()
GridCellRendererManager of the JGrid
GridCellRendererManager of the JGridGridCellRendererManager
public void setModel(ListModel model)
throws IllegalArgumentException
model - the new ListModel
IllegalArgumentException - if the model is nullgetModel()protected void revalidateAndRepaint()
protected ListSelectionModel createDefaultSelectionModel()
ListSelectionModel; called during
construction to initialize the grids selectionModel. Normally this
returns a DefaultListSelectionModel
JListpublic ListModel getModel()
JListpublic ListSelectionModel getSelectionModel()
JListpublic int getSelectedIndex()
ListSelectionModelpublic int getLeadSelectionIndex()
ListSelectionModelpublic GridUI getUI()
public void updateUI()
updateUI in class JComponentpublic void setFixedCellDimension(int dimension)
PropertyChangeEvent with the fixedCellDimension
propertyname
dimension - the new dimension for this Gridpublic void setVerticalMargin(int verticalMargin)
PropertyChangeEvent with the verticalMargin
propertyname
verticalMargin - the vertical margin for this Gridpublic void setHorizonztalMargin(int horizonztalMargin)
PropertyChangeEvent with the horizonztalMargin
propertyname
horizonztalMargin - the horizonztal margin for this Gridpublic int getFixedCellDimension()
public int getHorizonztalMargin()
public int getVerticalMargin()
public String getUIClassID()
getUIClassID in class JComponentpublic void setUI(BasicGridUI ui)
ui - the new UIpublic Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize in interface Scrollable
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction)
getScrollableBlockIncrement in interface Scrollablepublic boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight in interface Scrollablepublic boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth in interface Scrollable
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)
getScrollableUnitIncrement in interface Scrollablepublic Color getSelectionForeground()
public void setSelectionForeground(Color selectionForeground)
PropertyChangeEvent with the
selectionForeground propertyname
selectionForeground - the new selctionForegroundpublic void setSelectionBorderColor(Color selectionBorderColor)
PropertyChangeEvent with the
selectionBorderColor propertyname
selectionForeground - the new selctionForegroundpublic Color getSelectionBorderColor()
public Color getSelectionBackground()
public void setSelectionBackground(Color selectionBackground)
PropertyChangeEvent with the
selectionBackground propertyname
selectionBackground - the new selectionBackgroundpublic Color getCellBackground()
public void setCellBackground(Color cellBackground)
PropertyChangeEvent with the
cellBackground propertyname
cellBackground - the new default cellbackgroundpublic void setSelectedIndex(int index)
index - the index of the selected cellpublic Rectangle getCellBounds(int index)
index - the index of the cell
public int getCellAt(Point point)
point - the pint in the grid
BasicGridUIpublic String getToolTipText(MouseEvent event)
getToolTipText in class JComponentpublic GridCellRenderer getCellRenderer(int index)
index - the index of the cell
getCellRendererManager(),
setCellRendererManager(GridCellRendererManager),
GridCellRendererManagerpublic int getHorizontalAlignment()
LEFT /
CENTER / RIGHT / LEADING &
TRAILING allowed
public void setHorizontalAlignment(int alignment)
LEFT /
CENTER / RIGHT / LEADING &
TRAILING allowed Fires PropertyChangeEvent with
the horizontalAlignment propertyname
alignment - the new horizontal alignment
IllegalArgumentException - if alignment not LEFT /
CENTER / RIGHT /
LEADING & TRAILING
public int getIndexAt(int row,
int column)
row /
column
row - the row of the cellcolumn - the column of the cell
public int getColumnForIndex(int index)
modelIndex is in
selectedIndex - the model-index
public int getRowForIndex(int index)
modelIndex is in
selectedIndex - the model-index
public void setDefaultRenderer(GridCellRenderer defaultRenderer)
defaultRenderer will be used.
defaultRenderer - the new defaultRendererpublic GridCellRenderer getDefaultRenderer()
defaultRenderer will be used.
public void addRendererMapping(Class<?> cls,
GridCellRenderer renderer)
cls
cls - set the renderer for this classrenderer - the renderer for all instances of cls
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||