Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1576 > unrolled thread

Updating a Single Progres

Started by"Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this>
First post2011-04-27 15:34 +0000
Last post2011-04-27 15:34 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.lang.java.gui


Contents

  Updating a Single Progres "Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
    Re: Updating a Single Pro "Lionel van den Berg" <lionel.van.den.berg@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
      Re: Updating a Single Pro "Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
        Re: Updating a Single Pro "Michael Rauscher" <michael.rauscher@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000

#1576 — Updating a Single Progres

From"Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this>
Date2011-04-27 15:34 +0000
SubjectUpdating a Single Progres
Message-ID<1178309830.795758.96030@h2g2000hsg.googlegroups.com>
  To: comp.lang.java.gui
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.

>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.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#1585 — Re: Updating a Single Pro

From"Lionel van den Berg" <lionel.van.den.berg@THRWHITE.remove-dii-this>
Date2011-04-27 15:34 +0000
SubjectRe: Updating a Single Pro
Message-ID<463e9e6e$1@dnews.tpgi.com.au>
In reply to#1576
  To: comp.lang.java.gui
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.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#1594 — Re: Updating a Single Pro

From"Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this>
Date2011-04-27 15:34 +0000
SubjectRe: Updating a Single Pro
Message-ID<1178552408.753924.260070@e51g2000hsg.googlegroups.com>
In reply to#1585
  To: comp.lang.java.gui
On May 6, 11:35 pm, Lionel van den Berg <lione...@gmail.com> wrote:
> 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.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#1604 — Re: Updating a Single Pro

From"Michael Rauscher" <michael.rauscher@THRWHITE.remove-dii-this>
Date2011-04-27 15:34 +0000
SubjectRe: Updating a Single Pro
Message-ID<f1p65d$6ak$1@registered.motzarella.org>
In reply to#1594
  To: comp.lang.java.gui
Jason Cavett wrote sth. about JProgressBar in JTable:
> 
> 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

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web