Documents

Mig Layout

Description
MiG Layout Quick Start Guide v1.2.2 This is a quick start to MiG Layout. For further information look at www.migcomponents.com as it will be updated with links to the new and relevant information. To start using MiG Layout all you need to do is to download the miglayout.jar and include it in your project or classpath. There are different versions for Swing and SWT, but they work exactly the same. There is also a version for JSE 1.5 and one for 1.4 where the latter has varargs support in the API.
Categories
Published
of 7
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
  MiG Layout Quick Start Guide v1.2.2 This is a quick start to MiG Layout. For further information look at www.migcomponents.com as it will be updated with links to the new and relevant information.To start using MiG Layout all you need to do is to download the miglayout.jar and include it in your project or classpath. There are different versions for wing and !T but they work e#actly the same. There is also a version for $% &.' and one for &.( where the latter has varargs  support in the )*+. Adding Components to the Grid  )dding components to a ,ontainer is as simple as writing te#t and follows the same basic principle. +f you  just add them they will end up on the same row. !hen you want to change to ne#t row you specify the constraint -wrap- and the ne#t component will be on the ne#t row. For e#ample panel.add(comp1)panel.add(comp2)panel.add(comp3, wrap ) // Wrap to next rowpanel.add(comp4)comp1comp2comp3comp4 The grid can also be set to auto wrap at a specific column inde# by specifying that in the layout constraint when creating the layout manager. /e#t shows how to create the same grid without having to specify the -wrap- when adding comp3 . +t means that the grid should auto wrap  after column 0 and there will thus not be a fourth column. MigLao!t lao!t  new MigLao!t( wrap 3 )# From v1.' the ne#t row2s gap can be set directly after the wrap keyword. %.g panel.add(comp3, wrap 1$ ) will make the row gap &' pi#els high. 3ou can even make the gap -pushing- by specifying for instance - wrap p!s% -. Merging and Splitting Cells +t is equally easy to split   or span  cells. 4ere is how to create the ne#t grid. panel.add(comp1)panel.add(comp2, span 2 ) // &%e component will span two cells.panel.add(comp3, wrap ) // Wrap to next row panel.add(comp4, span ) // 'pan wit%o!t co!nt means span w%ole row.comp1comp2comp3comp4 pan optionally takes two inde#es x  and  . This means that you can span cells like this 5 1667 MiG +nfo,om )8  panel.add(comp1)#panel.add(comp2, span 2 2 )# // &%e component will span 2x2 cells.panel.add(comp3, wrap )# // Wrap to next row panel.add(comp4)#panel.add(comp$, wrap )# // ote t%at it !mps over t%e occ!pied cells.panel.add(comp*)#panel.add(comp+)#comp1comp4comp2comp3comp$comp*comp+ +t is equally easy and intuitive to split cells. panel.add(comp1)#panel.add(comp2, split 2 )# // 'plit t%e cell in twopanel.add(comp3)# // Will e in same cell as previo!spanel.add(comp4, wrap )# // Wrap to next rowpanel.add(comp$)#comp1comp2 comp3comp4comp$ +t is of course possible to both span  and split   cells at the same time. 3ou can for instance span three cells and split that three9cell9wide cell into two. Using Asolute Cell Coordinates +f you don2t want to use the -flow- way to put components into grid positions you can instead use absolute coordinates. For instance panel.add(comp1, cell - - )#// cell column   row  panel.add(comp2, cell 1 - )#panel.add(comp3, cell 2 - )#panel.add(comp4, cell - 1 )# !ould produce the same grid as the first e#ample at the top. comp1comp2comp3comp4 3ou can also use the absolute cell way to span and split cells. +f a component is put in a cell that already hasa component the cell will be split and both cells will end up in the same cell sharing its space. To make the same grid as the second e#ample above you do like this 5 1667 MiG +nfo,om )8  panel.add(comp1, cell - - )#panel.add(comp2, cell 1 - 2 1 )# // cell column row width height panel.add(comp3, cell 3 - )#panel.add(comp4, cell - 1 4 1 )#comp1comp2comp3comp4 Speci!ying Gaps Generally gaps are added where they make sense and this is performed on a platform by platform basis. For instance Mac S #  will have bigger gaps than !indows or Linu# in general. There are two kinds of gaps. Grid row gaps and ,omponent gaps. They default to proper values but you can change them however you like. Grid gaps +n the grid illustrations above they are the small spacing columns and rows between the real columns and rows. Their si:e can be set in the column and rows constraints when creating the layout manager ;or set on the layout manager object afterwards<. %.g. MigLao!t lao!t  new MigLao!t(  , // Lao!t onstraints  002-0 , // ol!mn constraints  02-0 )# // ow constraints would create something like this comp1comp2comp3comp4 where the bigger spacing row and column is 16 pi#els. 3ou can of course use any unit to specify the si:e but the default default is pi#els ;you can change this though<. For instance -16mm- will make it 16 millimeters wide./ote that from 1.' you can specify the gap when using the - wrap - keyword. %.g. - wrap 1$px -The space between the square brackets  (%ere..) 0  is the place where you specify the row and component constraints such as alignment and si:e. More on this later. Component gaps The only situation where there is a default component gap = 6 is between components in the same ;thus split< cell. 3ou can however change this by specifying a gap si:e when adding the component. Gaps around components is the distance to the closest edge may it be the cell -wall- or another component in the same cell. +f we use the first e#ample this is how it would be panel.add(comp1)panel.add(comp2, gaplet 3- ) 5 1667 MiG +nfo,om )8  panel.add(comp3, wrap ) // Wrap to next rowpanel.add(comp4)comp1 comp2comp3comp4 There are many gap constraints for instance gapeore  and gaptop . 3ou can read about them in the ,heat heet or !hite *aper on www.migcomponents.com . Component Si$es ,omponents have si:es provided by the G>+ framework in some way. wing even has support for minimum?preferred?ma#imum si:e while !T only has a preferred si:e. 3ou can override these si:es and for !T even e#tend the functionality by providing the si:es in the constraints. The si:es are specified in the form minpreerredmax  ;%.g. 1-2-4- <. ) si:e not specified will default to the component2s corresponding si:e ;%.g. 1-4-  will set the min and ma# si:e but preserve the srcinal preferred si:e<. There are a lot of short ways to set the si:es for instance 4-  means that all three si:es will be set to (6. %#amples panel.add(comp, widt% 1-2-4- )#panel.add(comp, %eig%t 4- )# // 'ame as %max 4- .panel.add(comp, w 4- )# // w is s%ort or widt%. %o& and Column si$es @ows and columns default to the si:e of the largest component in the column?row. This can be overridden and it works e#actly the same ways as the component si:es above. 3ou specify the column?row si:e in the corresponding constraint normally when creating the layout manager. 4ere are some e#amples MigLao!t lao!t  new MigLao!t(  , // Lao!t onstraints  1-02-3-4-04-04-0 , // ol!mn constraints  min01-2-04-mm0 )# // ow constraints Aid you see the min  partB min pre max  can be used on both component and column?row si:es to refer to the srcinal si:e. o min  means that minimum preferred and ma#imum si:e will all be set to the minimum si:e of the row ensuring the row will for sure get its minimum si:e. 'anel (nsets 8y default there will be an invisible border around the layout e#cept if you have docking components. The si:e of it is different on different platforms. ometimes this is not what you want or you just want to specify another inset. 3ou can change this in the layout constraint. %#amples 5 1667 MiG +nfo,om )8
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks