我使用netbeans binding填充了一个带有数据库数据的jtable。我想添加删除,插入和更新按钮来处理jtable和数据库中的数据更改...如何使用gui将按钮链接到操作? / p>
答案 0 :(得分:1)
您可以以类似的方式实现CRUD操作员按钮,并使用ActionListener
。插入行的示例如下:
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.
}
})