Reputation: 1
I populated a jtable with database data using netbeans binding.I would Like to add delete,insert and update buttons to act on data changes in jtable and the database...How can I link the buttons to actions using gui?
Upvotes: 0
Views: 1892
Reputation: 25950
You can implement CRUD operator buttons in a similar fashion, getting use of ActionListener
. Example for inserting a row is here:
JTable table = new JTable(model);
JButton button = new JButton();
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent arg0)
{
model.insertRow(0, new Object[]{"your data"});
// The above line manipulates data only in JTable.
// To reflect it on the database, add your SQL queries to this method.
}
})
Upvotes: 1