![]() ![]() Constraints such as sizes and default alignments can be specified. Specifies the properties for the grid's rows and columns. This constraint is set directly on the layout manager instance, either in the constructor or using a standard get/set property. For instance how all the laid out components should be aligned as a group, should there be available space in the container. These constraints specify how the layout manager instance should work in general. There are three constraint types that can be set on the layout manager instance and the handled components. They are seldom needed for normal layouts but they are very handy to have when exact and complex layouts are required. It also has numerous features to create stable and good looking layouts, many of which is known from FormLayout and GroupLayout.ĭo not let the vast amount of options make you think that this layout manager is hard to use. MigLayout can use many different unit types, such as millimeters or inches. One can even link components to eachothers' bounds. It does this outside the bounds of a grid. MigLayout can also position components absolutely or relative to the container's bounds, or even visual bounds, which is the bounds minus the insets. Flow can be vertical (y) or horizontal (x) and both the main grid and the individial cells can have different flow directions, though they default to horizontal flow. The components in a cell, if more than one, will be flowed much like FlowLayout do, but with more control over how it's done and without involuntary wrapping. The cells can even both be spanned and split at the same time making almost any conceivable layout possible, without resorting to "tricks". For instance, every cell can be split to contain more than one component, and several cells can be spanned (merged) to work as one big cell. The grid is very flexible and can for instance be tweaked more that an HTML table. MigLayout is using a grid (rows and columns) with automatic handling of gaps for default basic component layout. Components can be positioned with absolute coordinates and linked to other components' bounds, to the container, to component groups' bounds or to any combination of this using normal Java expressions. It is more flexible and than BorderLayout yet as easy to use. This add components at any of the four edges of the container, or in the center. It is more flexible than both GridBagLayout and JGoodies' FormLayout. This is the default mode and what is happening if you just add components and don't specify any of the other ways. You can for instance link a component's position to a component in the grid with absolute positioning and have it use the same vertical size as another component that is docked "north" in the container. ![]() They can be combined freely in the same container. There are three major ways to layout components with MigLayout. You can download the JavaDoc on the Mig Layout site. ![]() The API version will not be handleled furthere here since that would mostly be reiterating the same things twice. The API and String constraints are the same with some small differences that are documented in the JavaDoc for the API methods. The constraints used are all entered as Strings or through chained API method calls. Panel.add(new JTextField(""), new CC().wrap()) Sice they are so similar the API version will not be handled much further in this white paper. Or the same layout with the API constraint building. Panel.add(new JLabel("Enter weight:"), "") Panel.add(new JLabel("Enter size:"), "") MigLayout layout = new MigLayout("fillx", "rel", "10") Layout, Column and Row constraints as arguments. It is using the default ("related") gaps except for the inter-row gap which is 10 pixels. MiG Layout is free to use and is Open Source.Īn initial example that uses the grid funcitonality to create two rows with a right aligned label and a growing text field on each of the rows.GUI toolkit dependence put in three simple wrapper classes makes MiG Layout trivial to port to for instance.Docking, absolute positioning with component links and powerful grid layout all in one layout manager.Extensible Units that can can be used to layout components with everything from screen percentage to millimeters.MiG Layout is the most flexible layout engine to date, capable of doing everything that all major Layout Managers can, with one API. ![]() This means that whatever your preference is, String or API, you can use Mig Layout to create your layouts. From v2.0 there is also an API to create constraints.String based constraints makes the layout code portable, short, human readable and easy to implement for XUL and GUI builders.MigLayout is an extremely flexible layout manager that can be used in many different ways to layout components using a single and consistent API. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |