> > How did you go with the MouseListener?
>
> Thanks ;)
>
> Bye
> Michael
ok, now it works. this is the code:
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
jTable1.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
TableModel model = (TableModel)jTable1.getModel();
BigDecimal id =
(BigDecimal)model.getValueAt(jTable1.getSelectedRow(), 0);
String string = id.toString();
ElencoStudentiComunicazione nStud = new
ElencoStudentiComunicazione(string);
nStud.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
nStud.setVisible(true);
}
});
thanks for your help!
however I have 2 other problems.
1. I don't know how to "lock" the row in order not to let the user
edit it directly. If i doubleclick a cell, I can edit it, but I don't
want to let user do this. is there a property of the jtable?
2. When I open the second form (B) from A, and then I close B, I need
to "refresh" A, because maybe some values have changed. Is it
possible?
thanks
Michael Rauscher - 16 Mar 2007 06:11 GMT
> 1. I don't know how to "lock" the row in order not to let the user
> edit it directly. If i doubleclick a cell, I can edit it, but I don't
[quoted text clipped - 3 lines]
> to "refresh" A, because maybe some values have changed. Is it
> possible?
Do you know about MVC? Swing follows this approach.
JTable (together with it's UI delegate) provides a view to a TableModel.
To stay up to date JTable registers a TableModelListener with the
TableModel which informs it's listeners about any changes.
ad 1) Have a look at TableModel#isCellEditable.
ad 2) Have a look at AbstractTableModel#fireXXX methods.
Bye
Michael