Adding Button to JTable
I'm trying to add a button to a JTable, button when I do, it gives the object information. So how do I add the actuall botton in the JTable and have it clickable. Here is my code:
public CreateJTable(){
//createScroll();
DefaultTableModel model =new DefaultTableModel();
JTable table =new JTable(model);
System.out.println(System.getProperty("user.home"));
lst=new LinkedList();
// Create a couple of columns
model.addColumn("#");
model.addColumn("Category");
model.addColumn("Brand");
model.addColumn("Model");
model.addColumn("Code set");
model.addColumn("Location");
model.addColumn("Open");
//model.addColumn("Blank");
// Create the first row
//model.insertRow(0, new Object[]{"r1"});
JScrollPane scrollpane =new JScrollPane(table);
setSize(700, 200);
getContentPane().add(scrollpane);
setVisible(true);
runFileChooser();
breakdownFiles(files);
read=new ReadFiles();
for(int i=0;i<lst.size();i++){
//log.append((String) lst.get(i)+"\n");
File file=new File((String) lst.get(i));
read.runLoad(file);
}
for(int i=0; i><read.modelList.size();i++){
String model1, brand, category, codeset, savelocation;
int number;
model1=(String) read.modelList.get(i);
brand=(String) read.brandList.get(i);
category=(String) read.categoryList.get(i);
codeset=(String) read.codeList.get(i);
savelocation=(String) read.saveLocationlst.get(i);
number=i+1;
openButton=new JButton("Open");//Creating the Button
openButton.setPreferredSize(new Dimension(100,20));
model.insertRow(i,new Object[]{number, category, brand, model1, codeset, savelocation, openButton});//Addting the Button here
}
data=new CreateDataSheet(read.modelList,read.brandList,read.categoryList,read.codeList, read.saveLocationlst );
data.runSave();
data.writeToFile();
createSearchBrowser();
}//end constructor
>

