java - Reference to row in JTable -


jtable stores rows can added, deleted, shuffled, dynamically. in implementation row represent download, progress can dynamically updated, passing value of 1 of unique attribute called id. how map id actual row?

iterating on column not efficient approach. there way dynamically synchronize hashmap<id,object[]> jtable, such given key can update corresponding row, , vice versa?

private dfttasks=new defaulttablemodel(); public void addtask(string type, string name, int progress, int sessionid) {     object[] rowdata={type,name,new integer(progress),new integer(sessionid)};           dfttasks.addrow(rowdata); }  public void updateprogress(int sessionid, int progress) {     int = dfttasks.getrow(sessionid); //<--alternative method     dfttasks.setvalueat(new integer(progress), i, 2); //2nd column=progress } 

  1. create class encapsulate data (eg type, name, progress, , id).
  2. store instance of (1) in list, , if necessary other data structure quick access (eg map keyed id). order of list row order of table.
  3. extend abstracttablemodel, , implement necessary methods return values list (1) , (2) based upon row/column.
  4. when values of instances (2) changed (eg, progress updated), call firexxx within implementation in (3) (the source of defaulttablemodel example of how done)

Comments

Popular posts from this blog

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

node.js - Using Node without global install -

java - JavaScript + Thymeleaf - select onchange -