Java JTable Select getSelectedObject(JTable table)

Here you can find the source of getSelectedObject(JTable table)

Description

get Selected Object

License

Open Source License

Declaration

public static Integer[] getSelectedObject(JTable table) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JTable;

public class Main {
    public static Integer[] getSelectedObject(JTable table) {
        Integer[] selected = new Integer[2];

        int selectedRow = table.getSelectedRow();
        if (selectedRow >= 0) {
            selected[0] = (int) table.getModel().getValueAt(selectedRow, 0);
            selected[1] = (int) table.getModel().getValueAt(selectedRow, 1);

            return selected;
        } else {//from  w w  w .java  2  s  . c o m
            return null;
        }
    }
}

Related

  1. copyTableSelectionsToJList(JList list, JTable listTbl)
  2. createJCheckBoxForTable(boolean selected)
  3. disableSelection(JTable table)
  4. getSelectedCase(JTable table)
  5. getSelectionBackground(JTable t)
  6. invertSelect(JTable table)
  7. invertSelection(JTable table)
  8. moveSelectionDown(JTable table)