File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Question about initial dispaly of table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Question about initial dispaly of table" Watch "Question about initial dispaly of table" New topic
Author

Question about initial dispaly of table

Holmes Wong
Ranch Hand

Joined: Feb 18, 2002
Posts: 163
Hi, rachers:
I have a TableModel to store the search results. My question is: how do we set up the initial display of the table? put entire database in table model and display it, then refresh the table based on search results? or display an empty table first?---if I set cells to null, I get nullpinterexception. Any suggestion is appreciated.
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
set the table model with null Object[][] array in it. You should see a blank table.
Holmes Wong
Ranch Hand

Joined: Feb 18, 2002
Posts: 163
Thanks Sai:
I could display an empty table now. I still have trouble refresh the table. This is what I do not understand: if I display an empty table first like this:

Since the table is already added, once I get the search results, I have to do this again? :

I am confused here, the above code certainly will not work, should I use a TableModelListener to refresh table? Thanks.
christy smile
Ranch Hand

Joined: Oct 15, 2001
Posts: 101
Hi, I have a similar doubt in mind while designing the GUI. Then, I decided that I will display an empty table when the client first comes up. I supplied a button in the GUI called "ShowAll" that displays everything in db.db in the JTable. Anyone think this is a good idea?
Thanks.
dean tomlinson
Ranch Hand

Joined: Jan 31, 2002
Posts: 94
hi christy,
i personally think it is better to have just one button to execute the retrieval of the flights, based on the selections in your comboboxes / textfields.
i've got another button titled "reset" that sets my combo boxes to Any, so the user can easily retrieve all flights using 2 button clicks.
good luck with the assignment. dean
Holmes Wong
Ranch Hand

Joined: Feb 18, 2002
Posts: 163
Christy:
I think the idea about blank table or your idea
are both ok.
Guys:
I still cannot show the table for search results
after I set up an initial empty table. Should I define this blank table in my table model class then new a table model with null table values? Or define it in GUI without using table model first?
The latter seems not work. Any advice? Thanks.
Originally posted by christy smile:
Hi, I have a similar doubt in mind while designing the GUI. Then, I decided that I will display an empty table when the client first comes up. I supplied a button in the GUI called "ShowAll" that displays everything in db.db in the JTable. Anyone think this is a good idea?
Thanks.
christy smile
Ranch Hand

Joined: Oct 15, 2001
Posts: 101
Hi, Dean,
I have a "reset" button as well, which clears the origination and destination fields and display the whole database in JTable. Now, it seems "ShowAll" button is a bit redundant. With your reset button, do you field the fields with "any" or leave them blank? Mine leave the fields blank. I started a different thread about handling the blank textfield for criteriaFind, please take a look and give me your thoughts about it.
http://www.coderanch.com/t/181321/java-developer-SCJD/certification/initial-dispaly-table
Thanks
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
All you have to do is create only one instance of a JTable and only one instance of a TableModel. Table model can be either DefaultTableModel instance or you can extend AbstractTableModel and create your own model. In your table model, you provide methods to populate the two dimesional array or some collection in it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about initial dispaly of table