i have particular question. have table contains column has button. implemented button using class buttoncolumn found here: http://tips4java.wordpress.com/2009/07/12/table-button-column/. want progress bar appear when user clicks on button , task executing. when user clicks on button action executed using class swingworker. managed progress bar adding jprogressbar class , modifying gettablecellrenderercomponent() method include if-else statement such:
public component gettablecellrenderercomponent(jtable table, object value, boolean isselected, boolean hasfocus, int row, int column) { if ("update".equals(value.tostring())) { return renderbutton; } else { return renderbar; } }
i check see value of cell, if string "update" button returned, else progress bar returned. note progress bar indeterminate, don't care value in cell (this why cell value string). has worked in showing static progress bar. not moving. how make bar animated? have added propertychangelistener task extends class swingworker, , in listener update value of table cell (with random string) such:
final mytask task = new mytask(); task.addpropertychangelistener(new propertychangelistener() { @override public void propertychange(propertychangeevent evt) { if (evt.getpropertyname().equalsignorecase("progress")) { table.setvalueat(randomstring, row, col); int progress = task.getprogress(); if (progress == 100) { //set value "update" change bar button table.setvalueat("update", row, col); } } } });
the button changes static progress bar when clicked, , when task done becomes button again. problem in animation. tried overriding setvalueat function in tablemodel in order call firetablecellupdated(row, col) method had no effect.
update: when set bar determinate (and set integer values in table) animation works. when set indeterminate not.
Comments
Post a Comment