#how to update and send it to my file txt?

1 messages · Page 1 of 1 (latest)

half quarry
#

hello newbie here

sage karmaBOT
#

<@&987246399047479336> please have a look, thanks.

sage karmaBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

half quarry
#

my code is

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {                                     
        DefaultTableModel tblModel = (DefaultTableModel) jTable1.getModel();
        //File file = new File("users.txt");
        
        //set data to text fiel when row is selected
        String tblfn = tblModel.getValueAt(jTable1.getSelectedRow(), 0).toString();
        String tblmn = tblModel.getValueAt(jTable1.getSelectedRow(), 0).toString();
        String tblln = tblModel.getValueAt(jTable1.getSelectedRow(), 0).toString();
        
        txt_fn.setText(tblfn);
        txt_mn.setText(tblmn);
        txt_ln.setText(tblln);
        
    }                                    

    private void btn_uActionPerformed(java.awt.event.ActionEvent evt) {                                      
        File file = new File("users.txt");
        DefaultTableModel tblModel = (DefaultTableModel) jTable1.getModel();
        
        
        
                    if(jTable1.getSelectedRowCount() == 1){
                    String fname = txt_fn.getText();
                    String mname=txt_mn.getText();
                    String lname=txt_ln.getText();
        
                    tblModel.setValueAt(fname, jTable1.getSelectedRow(), 0);
                    tblModel.setValueAt(mname, jTable1.getSelectedRow(), 1);
                    tblModel.setValueAt(lname, jTable1.getSelectedRow(), 2);
        
        
        JOptionPane.showMessageDialog(this, "update");
        
    }else{
            if(jTable1.getRowCount()==0){
                JOptionPane.showMessageDialog(this, "empty");
            }else{
                JOptionPane.showMessageDialog(this, "select a row to update");
            }
        }
        
    }
sage karmaBOT
# half quarry my code is ``` private void jTable1MouseClicked(java.awt.event.MouseEvent evt) ...

Detected code, here are some useful tools:

Formatted code
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
  DefaultTableModel tblModel = (DefaultTableModel) jTable1.getModel();
  //File file = new File("users.txt");
  //set data to text fiel when row is selected
  String tblfn = tblModel.getValueAt(jTable1.getSelectedRow(), 0).toString();
  String tblmn = tblModel.getValueAt(jTable1.getSelectedRow(), 0).toString();
  String tblln = tblModel.getValueAt(jTable1.getSelectedRow(), 0).toString();
  txt_fn.setText(tblfn);
  txt_mn.setText(tblmn);
  txt_ln.setText(tblln);
}
private void btn_uActionPerformed(java.awt.event.ActionEvent evt) {
  File file = new File("users.txt");
  DefaultTableModel tblModel = (DefaultTableModel) jTable1.getModel();
  if (jTable1.getSelectedRowCount() == 1) {
    String fname = txt_fn.getText();
    String mname = txt_mn.getText();
    String lname = txt_ln.getText();
    tblModel.setValueAt(fname, jTable1.getSelectedRow(), 0);
    tblModel.setValueAt(mname, jTable1.getSelectedRow(), 1);
    tblModel.setValueAt(lname, jTable1.getSelectedRow(), 2);
    JOptionPane.showMessageDialog(this , "update");
  }
  else {
    if (jTable1.getRowCount() == 0) {
      JOptionPane.showMessageDialog(this , "empty");
    }
    else {
      JOptionPane.showMessageDialog(this , "select a row to update");
    }
  }
}
half quarry
#

i just want to save it need a clue on how to save it

quartz helm
half quarry
#

🥹 omg im so dum

half quarry
quartz helm
sage karmaBOT
#

Closed the thread due to inactivity.

If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you 👍

half quarry