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…

JList with ListSelectionModel.SINGLE_INTERVAL_SELECTION and ListSelectionModel.SINGLE_SELECTION

A JList allows the user to select multiple ranges of items within the list, but you can change this behavior by calling setSelectionMode( ), which is defined by JList. It is shown here: void setSelectionMode(int mode) Here, mode specifies the selection mode. It must be one of these values defined by¬†ListSelectionModel: SINGLE_SELECTION SINGLE_INTERVAL_SELECTION MULTIPLE_INTERVAL_SELECTION The … Read more…