Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   an array of JTables (http://www.velocityreviews.com/forums/t126691-an-array-of-jtables.html)

G.Schiber 09-14-2003 09:22 PM

an array of JTables
 
I have an array of JTables declared as:

JTable[] tableEntity = new JTable[maxMapEntities];

and instantiated as:

for (int i=0; i < maxMapEntities; i++)
tableEntity[i] = new JTable(tableData,tableColumns);

My gui is a map where I place entities. Each newly placed entity
increments an intEntityID by 1 and this is also used as the index in
the tableEntity array (index 0 is never used nor does it have to be).

When the user selects an entity and places it on the map(where the
mouse is clicked), I display a dialog which contains a JScrollPane
which contains the appropriate table. The code to do this is as
follows:

entityTableScroll = new JScrollPane(tableEntity[intEntityID]);
objsDialog.setContentPane(orderContainer);
objsDialog.getContentPane().add(entityTableScroll) ;

I have debugged and the intEntityID variable is being incremented
properly for each new entity placed on the map.

MY PROBLEM IS that a new blank tableEntity[] should be displayed for
each new entity but the previous tableEntity[]'s data is always
displayed. And when I save the data, each entity always has the same
data even though on the screen for that entity the data is different.
Any one else had a similar problem?

Thanks a lot,
Greg

Matt Humphrey 09-14-2003 09:44 PM

Re: an array of JTables
 

"G.Schiber" <gschiber@hotmail.com> wrote in message
news:203df6ae.0309141322.1d3a04b6@posting.google.c om...
> I have an array of JTables declared as:
>
> JTable[] tableEntity = new JTable[maxMapEntities];
>
> and instantiated as:
>
> for (int i=0; i < maxMapEntities; i++)
> tableEntity[i] = new JTable(tableData,tableColumns);


Just for curiosity, do all your JTables use the same data model? What do
tableData and tableColumns reference that make them into different tables?

Cheers,
Matt Humphrey matth@iviz.com http://www.iviz.com/

>
> My gui is a map where I place entities. Each newly placed entity
> increments an intEntityID by 1 and this is also used as the index in
> the tableEntity array (index 0 is never used nor does it have to be).
>
> When the user selects an entity and places it on the map(where the
> mouse is clicked), I display a dialog which contains a JScrollPane
> which contains the appropriate table. The code to do this is as
> follows:
>
> entityTableScroll = new JScrollPane(tableEntity[intEntityID]);
> objsDialog.setContentPane(orderContainer);
> objsDialog.getContentPane().add(entityTableScroll) ;
>
> I have debugged and the intEntityID variable is being incremented
> properly for each new entity placed on the map.
>
> MY PROBLEM IS that a new blank tableEntity[] should be displayed for
> each new entity but the previous tableEntity[]'s data is always
> displayed. And when I save the data, each entity always has the same
> data even though on the screen for that entity the data is different.
> Any one else had a similar problem?
>
> Thanks a lot,
> Greg




G.Schiber 09-15-2003 06:09 PM

Re: an array of JTables
 
Matt

Thanks for your reponse. Yes, my array of JTables use the same data
model defined by tableData (contains 10 rows of 8 blank columns) and
tableColumns(contains Column heading names for the table).

Greg

"Matt Humphrey" <matth@iviz.com> wrote in message news:<hj59b.790$065.493738@news1.news.adelphia.net >...
> "G.Schiber" <gschiber@hotmail.com> wrote in message
> news:203df6ae.0309141322.1d3a04b6@posting.google.c om...
> > I have an array of JTables declared as:
> >
> > JTable[] tableEntity = new JTable[maxMapEntities];
> >
> > and instantiated as:
> >
> > for (int i=0; i < maxMapEntities; i++)
> > tableEntity[i] = new JTable(tableData,tableColumns);

>
> Just for curiosity, do all your JTables use the same data model? What do
> tableData and tableColumns reference that make them into different tables?
>
> Cheers,
> Matt Humphrey matth@iviz.com http://www.iviz.com/
>
> >
> > My gui is a map where I place entities. Each newly placed entity
> > increments an intEntityID by 1 and this is also used as the index in
> > the tableEntity array (index 0 is never used nor does it have to be).
> >
> > When the user selects an entity and places it on the map(where the
> > mouse is clicked), I display a dialog which contains a JScrollPane
> > which contains the appropriate table. The code to do this is as
> > follows:
> >
> > entityTableScroll = new JScrollPane(tableEntity[intEntityID]);
> > objsDialog.setContentPane(orderContainer);
> > objsDialog.getContentPane().add(entityTableScroll) ;
> >
> > I have debugged and the intEntityID variable is being incremented
> > properly for each new entity placed on the map.
> >
> > MY PROBLEM IS that a new blank tableEntity[] should be displayed for
> > each new entity but the previous tableEntity[]'s data is always
> > displayed. And when I save the data, each entity always has the same
> > data even though on the screen for that entity the data is different.
> > Any one else had a similar problem?
> >
> > Thanks a lot,
> > Greg


Matt Humphrey 09-15-2003 06:55 PM

Re: an array of JTables
 

"G.Schiber" <gschiber@hotmail.com> wrote in message
news:203df6ae.0309151009.13882357@posting.google.c om...
> Matt
>
> Thanks for your reponse. Yes, my array of JTables use the same data
> model defined by tableData (contains 10 rows of 8 blank columns) and
> tableColumns(contains Column heading names for the table).


Ok. I'm thinking that because they share the same data model as the data
are updated by the first dialog, the data then appears in subsequent JTables
because they're really all the same. I don't think JTables copy the data as
an initial state, but use it as the underlying model. You may be able to
tell by creating mutiple tableData copies during JTable creation.

I havn't used JTables in a while, but normally views share references to
data.

Cheers,
Matt Humphrey matth@iviz.com http://www.iviz.com/




All times are GMT. The time now is 04:09 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.