Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how to bypass this swing limit

Reply
Thread Tools

how to bypass this swing limit

 
 
Peter Cheung
Guest
Posts: n/a
 
      09-16-2011
Dear All
how to by pass this swing limit:
Each GUI component can be contained only once. If a component is already in a container and you try to add it to another container, the component will be removed from the first container and then added to the second.

thanks
from Peter ((E-Mail Removed))
 
Reply With Quote
 
 
 
 
Daniele Futtorovic
Guest
Posts: n/a
 
      09-16-2011
On 16/09/2011 18:14, Peter Cheung allegedly wrote:
> Dear All
> how to by pass this swing limit:
> Each GUI component can be contained only once. If a component is already in a container and you try to add it to another container, the component will be removed from the first container and then added to the second.


Create a new component.

If you want the components to share state, then you ought to put that
state in a model object and make the components share the same model.
State should not be stored in the view anyway.

--
DF.
Determinism trumps correctness.
 
Reply With Quote
 
 
 
 
Peter Cheung
Guest
Posts: n/a
 
      09-16-2011
share the model can make two components display the same data. Except this, i need to create two set of event to handle mouse click, it is quite trouble.

thanks
 
Reply With Quote
 
Daniele Futtorovic
Guest
Posts: n/a
 
      09-16-2011
On 16/09/2011 18:47, Peter Cheung allegedly wrote:
> share the model can make two components display the same data. Except
> this, i need to create two set of event to handle mouse click, it is
> quite trouble.
>
> thanks


If you have, as you should, written a view/controller class that
initialises its layout, data and listeners, then the net difference
between one and two of those is one instantiation and addition to a
container.

It sounds like the design of your mouse event handler isn't right.

--
DF.
Determinism trumps correctness.
 
Reply With Quote
 
David Lamb
Guest
Posts: n/a
 
      09-16-2011
On 16/09/2011 12:47 PM, Peter Cheung wrote:
> share the model can make two components display the same data. Except this, i need to create two set of event to handle mouse click, it is quite trouble.


You originally wanted the same component in two containers. If the
container handles mouse clicks, and uses them to update the model state,
why do you need two sets of events? Only one of the two components is
going to get an incoming event at any one time.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-16-2011
On Fri, 16 Sep 2011 09:14:02 -0700 (PDT), Peter Cheung
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who said
:

>Dear All
> how to by pass this swing limit:
>Each GUI component can be contained only once.
> If a component is already in a container and you try to add it to another container,
>the component will be removed from the first container and then added to the second.


The obvious answer is clone the component, and make sure you keep them
up to date with the same state, e.g. by inventing a virtual component
that you update that in turn updates a list of clones for you.

Be careful with this kind of logic you don't create endless
notification loops.

--
Roedy Green Canadian Mind Products
http://mindprod.com
Your top priority should be fixing bugs. If you carry on development,
you are just creating more places you will have to search for them.

 
Reply With Quote
 
Peter Cheung
Guest
Posts: n/a
 
      09-19-2011
thanks everybody
Peter
 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Why not using javax.swing.event with swing? S.T Java 2 05-25-2007 12:10 AM
javax.swing.Popup, javax.swing.PopupFactory lizard Java 0 01-30-2006 09:34 PM
Swing Model Classes Updating Swing Components on a Thread Other Than AWT mkrause Java 0 05-06-2005 04:32 PM
Java 1.2 Swing vs. Java 1.5 Swing Big Daddy Java 2 04-16-2005 01:14 PM



Advertisments