Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!usenet.ukfsn.org!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: Sort a jtable within code Date: Wed, 12 Sep 2012 19:39:42 +0000 (UTC) Organization: UK Free Software Network Lines: 18 Message-ID: References: <114c9b7c-7ed8-4f59-aa46-c7480a677be7@googlegroups.com> NNTP-Posting-Host: 84.45.235.129 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: localhost.localdomain 1347478782 29556 84.45.235.129 (12 Sep 2012 19:39:42 GMT) X-Complaints-To: usenet@localhost.localdomain NNTP-Posting-Date: Wed, 12 Sep 2012 19:39:42 +0000 (UTC) User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Xref: csiph.com comp.lang.java.programmer:18688 On Wed, 12 Sep 2012 06:25:57 -0700, clusardi2k wrote: > How can I automatically sort a Jtable by a specific column within code, > and still allow the user to (later) sort any column by clicking on the > specific table header. > I've done it by initially loading a concrete extension of the AbstractTableModel from a sorted list of the rows that will display in the JTable. I handled resorting on a user-selected column by simply reloading the AbstractTableModel's extension with data sorted on the required column. The list was sorted by extracting it from a database using a SELECT....ORDERED BY SQL statement. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |