AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Updating a Single Progress Bar

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Jason Cavett
Guest





PostPosted: Sat May 05, 2007 1:17 am    Post subject: Updating a Single Progress Bar Reply with quote



Hello,

I'm trying to update a single JProgressBar that is contained within a
cell of a JTable in order to show the progress that has been completed
on analyzing some data. The JTable shows items that have already been
processed, the current item processing (there can only be one) and
items waiting to be processed.

Quote:
From the looks of things, I need to create my own TableModel (which I
did - it extends DefaultTableModel), I need to create my own

TableCellRenderer (which I did - it impelements TableCellRenderer AND
extends JProgressBar) and I need to add the renderer to the specific
column that will hold the JProgressBar.

So far, so good. Everything works.

The problem I have is that I don't have an apparent way to update the
value of the JProgressBar. For example, when a run finishes, the
JProgressBar should stay at 100. Then, the next item should be
processed going form 0 - 100. The progress of processing is
determined via another class (which is Observable). I am trying to
figure out how to update just the JProgressBar in question.

Sorry if this post rambles a bit. I am lost here. If anybody can
give me some insight, I'd appreciate it. I've been reading forums,
etc which is how I got to where I'm at now, but the whole updating
process doesn't seem to work as I thought it would.


Thanks for any clarification.
Back to top
Lionel van den Berg
Guest





PostPosted: Mon May 07, 2007 7:10 am    Post subject: Re: Updating a Single Progress Bar Reply with quote



Jason Cavett wrote:
Quote:
I am trying to
figure out how to update just the JProgressBar in question.

There's several ways you could do it. Can you pull out your code and
create an example of what you have? If you post that here we can help.

Also, what ISN'T working? I don't know what your program is doing as it
stands. I don't know if you are doing all of your processing from the
EDT or otherwise so I can't rule out that as being your problem.

Lionel.
Back to top
Jason Cavett
Guest





PostPosted: Mon May 07, 2007 8:40 pm    Post subject: Re: Updating a Single Progress Bar Reply with quote



On May 6, 11:35 pm, Lionel van den Berg <lione...@gmail.com> wrote:
Quote:
Jason Cavett wrote:
I am trying to
figure out how to update just the JProgressBar in question.

There's several ways you could do it. Can you pull out your code and
create an example of what you have? If you post that here we can help.

Also, what ISN'T working? I don't know what your program is doing as it
stands. I don't know if you are doing all of your processing from the
EDT or otherwise so I can't rule out that as being your problem.

Lionel.

I've been working on the program this morning and I've figured *some*
things out. The progress bar is now updatnig. The problem is that,
if I have multiple rows, ALL of their progress bars are updating when
I only want one to be updating (the one that is currently
processing). It seems as though every cell holds the same
ProgressBarRenderer and I'm not sure how to give each row its own
renderer (especially because the example I was using to help me figure
this out doesn't seem to do that).

Below is the initialization for the JTable. I update the table model
(which extends DefaultTableModel) via the Observer pattern. (The work
is being done in other classes and the progress bar is being updated
based on that work. I'm not even sure if this is the best way to do
it, but that's not my main problem.)

private JTable getRunningTable() {
if (runningTable == null) {
runningTable = new JTable(runTableModel);

// TODO set column widths

// don't allow dragging of columns
runningTable.getTableHeader().setReorderingAllowed(false);

// setup selection process

runningTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

// set column renderer for a JProgressBar
TableColumn col =
runningTable.getColumnModel().getColumn(RunView.PROGRESS_BAR_COLUMN);
col.setCellRenderer(new ProgressBarRenderer());
}
return runningTable;
}


Thanks for your help.
Back to top
Michael Rauscher
Guest





PostPosted: Tue May 08, 2007 7:10 am    Post subject: Re: Updating a Single Progress Bar Reply with quote

Jason Cavett wrote sth. about JProgressBar in JTable:
Quote:

I've been working on the program this morning and I've figured *some*
things out. The progress bar is now updatnig. The problem is that,
if I have multiple rows, ALL of their progress bars are updating when
I only want one to be updating (the one that is currently
processing). It seems as though every cell holds the same
ProgressBarRenderer and I'm not sure how to give each row its own
renderer (especially because the example I was using to help me figure
this out doesn't seem to do that).

The problem isn't the single renderer but the single value. Whenever
TableModel#getValueAt is called with a column of PROGRESS_BAR_COLUMN it
should return the current progress of the given 'row' (e. g. as
Integer). The renderer then can use the value parameter in
getTableCellRendererComponent to set the current progress value of the
JProgressBar.

Bye
Michael
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.