Two JTable questions

J

jb

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
 
J

John

jb said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top