Posted By:
prasanna_d
Posted On:
Sunday, November 1, 2009 11:40 PM
can any one plzz help to put a JButton in JTable column public class TABLEE extends tablee1 { public static void main(String args[]) { JFrame frame = new JFrame(); int i=0; DBConnection db=new DBConnection(); Statement stmt=null; frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E); Object row[][] = { }; JButton btn= new JButton(); //how to add this btn button in the thrid column Object col[] = { "Reference Paper Name", "Author" ,"Link"}; DefaultTableModel table1=new DefaultTableModel(row,col); JTable table = new JTable(table1); JScrollPane scrollPane = new JScrollPane(table);
More>>
can any one plzz help to put a JButton in JTable column
public class TABLEE extends tablee1 {
public static void main(String args[]) {
JFrame frame = new JFrame();
int i=0;
DBConnection db=new DBConnection();
Statement stmt=null;
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
Object row[][] = { };
JButton btn= new JButton();
//how to add this btn button in the thrid column
Object col[] = { "Reference Paper Name", "Author" ,"Link"};
DefaultTableModel table1=new DefaultTableModel(row,col);
JTable table = new JTable(table1);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(1000, 750);
frame.setVisible(true);
try
{
String query="select * from reference where base_id='bp5'";
stmt=db.getConnection().createStatement();
PreparedStatement ps=db.getConnection().prepareStatement(query);
ResultSet rs=ps.executeQuery();
while(rs.next())
{
//how to add this btn button in the thrid column
table1.insertRow(i,new Object[]{rs.getString(2),rs.getString(3),//Button add here });
i++;
}
}
<<Less