Which LayoutManager can be used if I have to add components at arbitary locations on a Container?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abey_Mullassery
Posted On:   Monday, May 7, 2001 03:26 AM

If I need to develop a visual representation of something like a Circuit Board which is made up of other components, which LayoutManager would be the best.
These clickable (MouseListeners) components (sub-class of JComponent) should be added to any location on the "Circuit Board" (a JPanel).


It should ideally be able to arrange these components and the connections on resize, maximize, etc., like the available layoutManagers.

Re: Which LayoutManager can be used if I have to add components at arbitary locations on a Container?

Posted By:   Scott_Stanchfield  
Posted On:   Tuesday, May 22, 2001 07:32 AM

You have two choices on this:


  1. Create your own layout manager to position/size the components
  2. Use "no layout" for this


For drawing applications, it's often easier to use no layout manager (and would be one of the very few in which you should ever choose to not use a layout manager)

However, if you want to implement a "snap to grid", you could write a "SnapLayout" that looks at each component and moves/resizes them to the closest spacing unit you want to use. That would simplify a good bit of the app.

I recommend that you do not link window resizing to these "chips" resizing -- you should let the user resize the window to have more room to add pieces, not make everything bigger.

About | Sitemap | Contact