Popular Posts

Java Add Row To JTable From Another JFrame

Share it:

How To Insert A Row To JTable From A Different Form In Java Using NetBeans

add row to jtable from another jframe in java



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 : 

Add Row To JTable From Different JFrame In Java



Share it:

add row to jtable

Add Row To JTable From Another JFrame

How To Insert A Row To JTable From A Different Form In Java

java

JFrame

jtable

jtable row

Post A Comment:

0 comments: