how to bypass this swing limit

P

Peter Cheung

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 ([email protected])
 
D

Daniele Futtorovic

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

Peter Cheung

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
 
D

Daniele Futtorovic

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

David Lamb

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

Roedy Green

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.
 

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,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top