java - How to sort only specified columns in JTable? -


i have table columns | name | start | finish | time | place | points | , want keep place , points isolated when sorting table time. there way without creating 2 tables?

so, came using tablecellrenderer place , points columns manu suggested sharing this link.

firstly, created customtablecellrenderer , used method set values:

public class customcellrenderer extends jlabel implements tablecellrenderer{      ...      @override     public component gettablecellrenderercomponent(jtable table, object value,     boolean isselected, boolean hasfocus, int row, int column) {          if(column==this.columnplace){             // set place          settext(integer.tostring(row+1));         }         else{          // set points depending on competitorscount , row             settext(integer.tostring(points[competitorscount-1][row]));         }         return this;     } } 

and set custom renderer these columns:

    customcellrenderer customrenderer = new customcellrenderer(competitorscount);     customrenderer.sethorizontalalignment(jlabel.center);     tablecolumnmodel.getcolumn(columnplace).setcellrenderer(customrenderer);     tablecolumnmodel.getcolumn(columnpoints).setcellrenderer(customrenderer); 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -