JTable with ListSelectionListener and getSelectedRow

The getSelectionRow () returns an integer value of the selected row . Program       Program Source import javax.swing.JFrame; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionEvent; import java.awt.Dimension; import java.awt.FlowLayout; class Frame extends JFrame implements ListSelectionListener{ private JTable jt; private JTextArea ta; private ListSelectionModel ls; private String[] heading = … Read more…

JTable

JTabel provides a very flexible capability for creating and displaying tables. It allows tables that can be constructed from arrays and vectors of objects. Program       Program Source import javax.swing.JFrame; import javax.swing.JTable; import javax.swing.JScrollPane; import java.awt.Dimension; import java.awt.FlowLayout; class Frame extends JFrame { Frame() { setTitle(“JTable”); setLayout(new FlowLayout()); setJTable(); setSize(700,200); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } … Read more…