Here you can find the source of getSelectedObject(JTable table)
public static Integer[] getSelectedObject(JTable table)
//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; } } }