AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

JTable.addColumn and RowSorter.setSortKeys

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language (German)
View previous topic :: View next topic  
Author Message
Thomas Lehmann
Guest





PostPosted: Mon Jul 16, 2012 10:24 am    Post subject: JTable.addColumn and RowSorter.setSortKeys Reply with quote



You might wonder how this relates (title)...

When using "addColumn" on a table instance the model will be not adjusted to it; this means that "model.getColumnCount()" is zero but table.getColumnCount() is > 0.

My problem now is a simple row sorter (taken from Java Tutorial page) which
asks the model for the number of columns...

What I did - it's working so far - is:

model.setColumnCount(table.getColumnCount());

Is this the recommended solution? (I believe not)

Please, could somebody provide help?

Thanks,
Thomas
Back to top
Claus Reibenstein
Guest





PostPosted: Tue Jul 17, 2012 5:22 pm    Post subject: Re: JTable.addColumn and RowSorter.setSortKeys Reply with quote



Thomas Lehmann schrieb:

Quote:
You might wonder how this relates (title)...

Vor allem frage ich mich, warum Du hier englisch schreibst ...

Quote:
When using "addColumn" on a table instance the model will be not adjusted to it; this means that "model.getColumnCount()" is zero but table.getColumnCount() is > 0.

Diese überlangen Zeilen solltest Du Dir auch abgewöhnen.

Gruß
Claus
Back to top
S.van Heek
Guest





PostPosted: Tue Jul 17, 2012 5:44 pm    Post subject: Re: JTable.addColumn and RowSorter.setSortKeys Reply with quote



Am Montag, 16. Juli 2012 12:24:20 UTC+2 schrieb Thomas Lehmann:
Quote:
You might wonder how this relates (title)...

When using "addColumn" on a table instance the model will be not adjusted to it; this means that "model.getColumnCount()" is zero but table.getColumnCount() is > 0.

My problem now is a simple row sorter (taken from Java Tutorial page) which
asks the model for the number of columns...

What I did - it's working so far - is:

model.setColumnCount(table.getColumnCount());

Is this the recommended solution? (I believe not)

Please, could somebody provide help?

Thanks,
Thomas

Here is an example:

http://www.exampledepot.com/egs/javax.swing.table/AppendCol.html
Back to top
Thomas Lehmann
Guest





PostPosted: Fri Jul 20, 2012 9:56 am    Post subject: Re: JTable.addColumn and RowSorter.setSortKeys Reply with quote

Erst mal tdschuldigung wegen dem Englisch ...
das kommt durch die Firma wo ich arbeite.

a) Ich rufe NICHT addColumn über das Model
sondern über die Table auf!
b) Dabei kann ich mit New TableColumn einen
frei definierbaren Index angeben; dafür
habe ich eine Enum Konstante.

Klartext: Bspw. 3 Spalten aber die Indize sind 1, 9, 41.

Deswegen muss man an ein paar Stellen die Konvertiermethoden
der Table nehmen (model <-> view).

Zurück zu meiner (englischen) Beschreibung:

Gehe ich diesen Weg dann liefert mein Model "getColumnCount()" -> 0.
Woher soll das Model es denn wissen?

Also setze ich die "3" in das Model (setColumnCount).
Aber auch nur deswegen weil der TableRowSorter auf "getColumnCount()"
zugreift.

Übrigens passieren die gleichen Probleme wenn man auf die Spalte klickt.
Ist der Wert der Konstante größer/gleich als die Anzahl der Spalten...

Entweder sind das Fehler im TableRowSorter Konzept oder ich habe irgendwas
wesentliches verpasst.

Könnte mir da jemand bitte weiterhelfen?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.