java - Can't add a row to a jTable even when using getModel -


I have been searching through this website for several hours so far my button is already present in a row table This table is created by simply clicking on swing controls and adding a table and changing the field through properties.

The table's variable name is 'Table'.

And when faced with this line of code: table.getModel (). InsertRow (table.getRowCount (), new object [] {NOM [i], data [i]});

The 'InsertRow' part is redded and I can not seem to fix it.

  Private zeros jButton1ActionPerformed (java.awt.event.ActionEvent evt) {string direcdate = direc1.getText (); File folder = new file (direcdate); File [] listOfFiles = folder.listFiles (); String [] noam = new string [250]; String [] data = new string [250]; Int i = 0; For (file listoffuffy: listofffiles) {simple data formatting sdf = new simpledataformat ("dd / mm / yay"); If (listOfFile.isFile ()) {nome [i] = listOfFile.getName (); Data [i] = sdf.format (listOfFile.lastModified ()); I ++; } And if (listOfFile.is directory ()) {nome [i] = "folder:" + listOfFile.getName (); Data [i] = sdf.format (listOfFile.lastModified ()); I ++; }} For (integer = 0; increase & lt; i; increm ++) {table.getModel (). InsertRow (table.getRowCount (), new object [] {NOM [i], data [i]}); }}  

Any ideas or suggestions?

Edit: Where table model is located: Public class GAPAC_TESTE increases javax.swing.JFrame {

  public GAPAC_TESTE () {initComponents (); Ultimaalt.setText ("0"); JTextPane2.setText ("Apos escultor a Dorratoria, Escola ima des apocryo."); DefaultTel Model Model = new javax.swing.table.DefaultTableModel (); Table = new javax.swing.JTable (model); }  

  table .getModel ().  

Return a table to that method Have you seen the API for the tablemodel interface? There is no insertRow (...) method in it.

insertRow (...) in DefaultTableModel method is therefore using the default TableModel handling your table code:

  DefaultTableModel Model = (DefaultTableMode) table.getModel (); Model.insertRow (...);  

Do not always write code in the same statement. Break the statement in many statements so that you can understand which part of the statement causes the problem and it ensures that you specify the variable to the appropriate class.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -