Java JTable Not populating with DefaultTableModel -


i have jtable trying populate file names located in particular folder.

i can load jtable , looks if being populated data, no test appears in jtable rows.

i can tell loading files, when place 2 files in folder, jtable creates 2 rows when loads. can change number of files in folder, , when re run program, load exact number of rows files in folder.

any ideas? used methods of populating several other tables, , seem work, i'm confused why 1 doesn't.

package testtable;  import java.awt.borderlayout;   public class main extends jframe {  public jpanel contentpane; public jtable table; public defaulttablemodel rulesmodel;   /**  * launch application.  */ public static void main(string[] args) {     eventqueue.invokelater(new runnable() {         public void run() {             try {                 main frame = new main();                 frame.setvisible(true);             } catch (exception e) {                 e.printstacktrace();             }         }     }); }  /**  * create frame.  */ @suppresswarnings("serial") public main() {     setdefaultcloseoperation(jframe.exit_on_close);     setbounds(100, 100, 450, 300);     contentpane = new jpanel();     contentpane.setborder(new emptyborder(5, 5, 5, 5));     setcontentpane(contentpane);      jscrollpane scrollpane = new jscrollpane();     grouplayout gl_contentpane = new grouplayout(contentpane);     gl_contentpane.sethorizontalgroup(         gl_contentpane.createparallelgroup(alignment.trailing)             .addgroup(alignment.leading, gl_contentpane.createsequentialgroup()                 .addcontainergap()                 .addcomponent(scrollpane, grouplayout.default_size, 414, short.max_value))     );     gl_contentpane.setverticalgroup(         gl_contentpane.createparallelgroup(alignment.leading)             .addgroup(gl_contentpane.createsequentialgroup()                 .addcontainergap()                 .addcomponent(scrollpane, grouplayout.preferred_size, 187, grouplayout.preferred_size)                 .addcontainergap(54, short.max_value))     );         rulesmodel = new defaulttablemodel();     rulesmodel.setcolumnidentifiers(new string[] {"file name"});      table = new jtable(rulesmodel) {         public boolean iscelleditable(int row, int column) {             return false;         }         public component preparerenderer(tablecellrenderer renderer, int row, int column) {             return (component) null;         }     };       file folder = new file("c:\\scripts\\new\\files\\folder\\");     file[] listoffiles = folder.listfiles();      (file file : listoffiles) {         if (file.isfile()) {             string filename = file.getname();              rulesmodel.addrow(new string[] {filename});             system.out.println(filename);         }     }              table.setmodel(rulesmodel);     scrollpane.setviewportview(table);     contentpane.setlayout(gl_contentpane); }   } 

this messing up:

 public component preparerenderer(tablecellrenderer renderer, int row,        int column) {     return (component) null;  } 

it takes whatever cell renderer exists jtable, tosses aside , guarantees table not display information. rid of faulty override.

although beg question:
why code in there it's guaranteed make sure nothing displays @ all? why rid of cell renderer?


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -