Re: How to create expanding Tables (Web 2.0 Style) with Swing ?
- From: Josh Falter <jfalter@xxxxxxxxx>
- Date: 24 Apr 2007 06:48:17 -0700
I have never attempted this, so I don't know if it would work, but
here is what I would try....
Start with a JTable that you have created a custom TableModel for (so
that you can control the data organization). Add a
MouseMotionListener to the JTable. When a MouseEvent event is
received, create a Point Object from the coordinates of the event
(using MouseEvent.getPoint) and use the JTable functions
columnAtPoint() and rowAtPoint() to determine if having the mouse over
this location in the JTable should cause the data to change. If new
data should then be shown, I would call some custom function in the
TableModel that would insert a new row and set some flags that would
be used in the getValueAt() function to inject the new data into the
next row and move all the other data down a row. Then call
fireTableDataChanged() to get the GUI to update the data displayed.
You would also then have to listen for when the Mouse has moved to a
new location so that you can delete that extra row and reset the data,
which would probably involve the MouseMotionListener as well as a
MouseListener to determine if the mouse has left the component all
together.
HTH - Josh
.
- Follow-Ups:
- References:
- Prev by Date: Re: japplet param
- Next by Date: Point in java.awt.geom
- Previous by thread: Re: How to create expanding Tables (Web 2.0 Style) with Swing ?
- Next by thread: Re: How to create expanding Tables (Web 2.0 Style) with Swing ?
- Index(es):