How To Insert A Row To JTable From A Different Form In Java Using NetBeans
In this Java Tutorial we will see How To Get Data From JTextFields And Add It To A Jtable Row From A Different JFrame Using Java NetBeans .
Project Source Code:
//************** in the jtable jframe **************//
// button to display a jframe with jtextfields
private void jButtonOpenActionPerformed(java.awt.event.ActionEvent evt) {
JFrame_TextFiled frameText = new JFrame_TextFiled();
frameText.setVisible(true);
frameText.pack();
frameText.setLocationRelativeTo(null);
frameText.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
// function to add row
public static void AddRowToJTable(Object[] dataRow)
{
DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
model.addRow(dataRow);
}
//************** in the jtextfields jframe **************//
// Button to add row
private void jButtonAddActionPerformed(java.awt.event.ActionEvent evt) {
JFRAME_JTABLE.AddRowToJTable(new Object[]{
jTextField1.getText(),
jTextField2.getText(),
jTextField3.getText(),
});
}
////// OUTPUT :
Post A Comment:
0 comments: