Avatar billede jose Nybegynder
16. maj 2000 - 19:48 Der er 3 kommentarer og
1 løsning

Om GUI´s and tables

Imagine that you have to print a JTable, but the outcoming data depends on a decidion made by the User in the same Frame...
In my case the user selects a field in a JList (represents an Object that contains a vector of vectors). The information is now passed to the JTable´s constructor.
So when the user goes back and selects another field in the JList, the table should now change it´s data... but of course it doesn´t (what a surprise in java...)
Is there anyone that can help me?.
Jose.
Avatar billede jose Nybegynder
16. maj 2000 - 21:19 #1
Well, It´s possible to have to different aplications. The first with the Jlist and a JButton, so when you make a selection in the table and the button is clicked you close the first aplication and starts with the second aplication, that has the table with the data you need... but this is not so smart...
Avatar billede gnarf Nybegynder
16. maj 2000 - 23:30 #2
Either you have to make it possible for the JTable to configure itself, each and every time the user selects a new field. I dont know if JTable has this functionality already, but instead, you could pass the newly selected field to a new JTable's constructor, and put the new JTable in the old JTable's place, and then update/repaint your frame.

It would of course involve an awful lot of object construction, which is not the fastest thing you can do, but it should be possible.
Avatar billede andersb Nybegynder
17. maj 2000 - 09:19 #3
You need to use JTables underlying TableModel. If anything changes in the model it'll also change in the UI, i.e. the JTable.
See the description in http://java.sun.com/products/jdk/1.2/docs/api/javax/swing/JTable.html
and http://java.sun.com/products/jdk/1.2/docs/api/javax/swing/table/TableModel.html
For a deeper description with examples refer to http://java.sun.com/docs/books/tutorial/uiswing/index.html
- Anders

Avatar billede jose Nybegynder
20. maj 2000 - 17:42 #4
TableModel is the better solution, it takes so long to find out how it works, but is cool. Thanks.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester