Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Two JTable questions

Reply
Thread Tools

Two JTable questions

 
 
jb
Guest
Posts: n/a
 
      06-05-2006
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

 
Reply With Quote
 
 
 
 
John
Guest
Posts: n/a
 
      06-08-2006

jb wrote:
> 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


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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JTable questions news.otenet.gr Java 2 07-12-2007 07:35 AM
Putting a JTable inside a JTable cell? Tivo Escobar Java 1 04-12-2007 11:09 AM
How to move data from a CSV file to a JTable, and from a JTable to a CSV file ? Tintin92 Java 1 02-14-2007 06:51 PM
Questions About JTable Cell Editing? RC Java 0 12-07-2006 12:56 PM
How to compare two SOAP Envelope or two Document or two XML files GenxLogic Java 3 12-06-2006 08:41 PM



Advertisments