Discussion:
How Can we add a ListBox in a JTable Cell
(too old to reply)
Faisal
2004-07-15 04:04:45 UTC
Permalink
Hi People
I am a new b to GUI development in java ,
I wanted to know that can we add a JList to a JTable cell.
What i want to do is that in a JTable cell i want to select a item
from a set of available item and the rest of the cell of that row
will be updated based on the selection of that cell
for example i am creating an application that displays stock quotes in
a JTable the user will select that symbol from the JList and
corresponding to his selection the rates and volume details of the
symbol will appear by communicating to a webserver etc.

Thanx in advance
Tor Iver Wilhelmsen
2004-07-15 07:03:06 UTC
Permalink
Post by Faisal
What i want to do is that in a JTable cell i want to select a item
from a set of available item and the rest of the cell of that row
will be updated based on the selection of that cell
You need to do two things:
1) Set a custom CellEditor for that column which uses a JComboBox.
2) In setValueAt() in your table model, compute the other values and
tell the "view" that the whole row has changed.
Nigel Wade
2004-07-15 09:36:50 UTC
Permalink
Post by Faisal
Hi People
I am a new b to GUI development in java , I wanted to know that can we
add a JList to a JTable cell. What i want to do is that in a JTable cell
i want to select a item from a set of available item and the rest of
the cell of that row will be updated based on the selection of that cell
for example i am creating an application that displays stock quotes in a
JTable the user will select that symbol from the JList and corresponding
to his selection the rates and volume details of the symbol will appear
by communicating to a webserver etc.
Thanx in advance
In a table a JComboBox would probably be more appropriate. Have a a look
at:

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#combobox
--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : ***@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
Loading...