Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Two JTable questions

Thread view: 
jb - 05 Jun 2006 18:38 GMT
Well I'm writing a database program that is supposed to store contents
of a warehouse (well small warehouse, really small warehouse). And to
have a user-friendly GUI.
And I thought that displaying entire contents of database (backed by a
filtering mechanism) is a good idea. I did implement my own TableModel
- I needed it to respond to changes made in the database, to add
editing capabilities etc.
getValue looks like that:
All columns except one uses default renderer and stores values
converted to strings.
The odd-one column returns a class named ExpenditureDsplayPanelv2 that
is extending JPanel that consists of combo box, and a button. It also
uses custom home-brewed renderer that just returns the value stored in
this cell.
There is the extract of the getValueAt method
   switch(column){
   case NAMECOLUMNNUMBER:  // its static final int
     try{
       return productVect.get(row).getName();
     }
     catch(ZZIllegalEx e){
       return notSetMessage; //A string too.
     }

    //Other columns had been cut.

    case EXPENDITURESCOLUMNNUMBER:
        return new ExpenditureDsplayPanelv2 ( // <- Here (extends
JPanel)
            productVect.get(row),
            getOwner()
        );
 }

Renderer looks like that:
   public Component getTableCellRendererComponent(JTable arg0, Object
arg1,
       boolean arg2, boolean arg3, int arg4, int arg5) {
     return (Component) arg1; //Works since arg1 is a JPanel thus
Component
   }

First problem is that the whole table works slooow (the Table has
approx. 100 rows, and 11 columns).
So is the slowness a fault of my clumsy programming (well I admit it is
my first contact with JTables), and if so how could I make it faster.
Just give me some hints - i'll work out the rest myself ;-).
The second is that ExpenditureDsplayPanelv2 (as I have said it extends
JPanel) though displaying properly, doesn't react on clicking on it
(while when not in JTable it works ). Once again is it fault of my
clumsiness, or I just over-estimated power of JTable. And if having
user responding button as a part of JTable is impossible please suggest
me how to go round it. And setting this collumn as editable won't work.

Thanks in advance :-)
-jb
John - 08 Jun 2006 14:49 GMT
> Well I'm writing a database program that is supposed to store contents
> of a warehouse (well small warehouse, really small warehouse). And to
[quoted text clipped - 52 lines]
> Thanks in advance :-)
> -jb

Perhaps the problem can be put down to the JDBC implementation? Some
database  may implement scrollable cursors in slow way perhaps? Have
you tried reading the results of the entire query into an array or
something? that might speed it up. Other than that I would run it
through a profiler.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.