How to add JButton to each cell of JTable

I am new in swing. I have a code of that shows JTable but I want to add JButton to each cell of JTable.

My JTable Code is

public enum ShowTable{

INSTANCE;

private JFrame f = new JFrame("IP's");

DefaultTableModel model=new DefaultTableModel(){

@Override

public boolean isCellEditable(int Row,int Column){

return false;

}

};

private final JTable jt = new JTable(model);

private ShowTable() {

jt.setBounds(30, 40, 200, 300);

jt.setFocusable(false);

jt.setRowSelectionAllowed(false);

jt.setEnabled(false);

JScrollPane sp = new JScrollPane(jt);

f.add(sp);

f.setSize(1300, 600);

}

public void showdata(int count,String host,String ip,String username,String os_name,String os_arch,String pro_detail,String Mac_add,float disk_size,float max_memory){

Object data[]={count,host,ip,username,os_name,os_arch,pro_detail,Mac_add,disk_size,max_memory};

if (count == 1)

{

model.addColumn("S No.");

model.addColumn("HOSTNAME");

model.addColumn("IP ADDRESS");

model.addColumn("USERNAME");

model.addColumn("OS NAME");

model.addColumn("OS ARCHITECTURE");

model.addColumn("PROCESSOR DETAIL");

model.addColumn("MAC ADDRESS");

model.addColumn("HARD DISK (GB)");

model.addColumn("RAM SIZE (GB)");

model.addRow(data);

}

else

{

model.addRow(data);

}

f.setVisible(true);

}

}

I want to add JButton...

Read More »

By: StackOverFlow - Wednesday, 14 March

Related Posts