tie UI Student table to database student table
[se-panther.git] / gui-playground / src / panther / ui / StudentSelectionListener.java
blobc9beed46b384aced83cc9f204fbe63b85304ce1c
1 package panther.ui;
3 import javax.swing.*;
4 import javax.swing.event.*;
5 import javax.swing.table.*;
7 import panther.db.*;
9 public class StudentSelectionListener
10 implements ListSelectionListener
12 private JTable master;
13 private JTable detail;
15 public StudentSelectionListener(JTable master, JTable detail)
17 this.master = master;
18 this.detail = detail;
21 public void valueChanged(ListSelectionEvent e)
23 if (e.getValueIsAdjusting()) return;
25 int m_idx = master.convertRowIndexToModel(master.getSelectedRow());
27 Object student_o = master.getModel().getValueAt(m_idx, 0);
28 if (student_o instanceof Student) {
29 Student student = (Student) student_o;
31 TableModel tmodel_o = detail.getModel();
32 if (tmodel_o instanceof SessionTableModel) {
33 SessionTableModel tmodel = (SessionTableModel) tmodel_o;
35 tmodel.update_student_sessions(student.get_id());