Documentation

Trace:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
jvx:client:gui:layoutmanager [2018/02/01 12:26]
admin
jvx:client:gui:layoutmanager [2020/11/18 07:35] (current)
admin
Line 1: Line 1:
-~~Title: Layout ​Manages~~+~~Title: Layout ​Managers~~
  
 One can hardly imagine GUI development with layout managers. However, often multiple layout managers are necessary to develop appealing GUIs. These layout mangers are usually nested to achieve the desired results. To facilitate nesting, a panel is required for each layout manager. Before you know it, a large amount of code is created just to define the GUI.  One can hardly imagine GUI development with layout managers. However, often multiple layout managers are necessary to develop appealing GUIs. These layout mangers are usually nested to achieve the desired results. To facilitate nesting, a panel is required for each layout manager. Before you know it, a large amount of code is created just to define the GUI. 
  
-The use of visual designers only eases positioning of the components; it does not reduce the number of components. Also, the more nesting is used for a GUI, the more sluggish and complex it becomes. ​+The use of visual designers only eases the positioning of the components; it does not reduce the number of components. Also, the more nesting is used for a GUI, the more sluggish and complex it becomes. ​
  
 To keep the GUI code at a minimum and to keep it manageable, JVx offers three layout managers that can help accomplish this goal: To keep the GUI code at a minimum and to keep it manageable, JVx offers three layout managers that can help accomplish this goal:
Line 11: Line 11:
   * FormLayout   * FormLayout
  
-BorderLayout,​ unlike //​java.awt.BorderLayout//,​ allows the setting of margins. Otherwise it offers the usual regions: NORTH, WEST, EAST, SOUTH, and CENTER.+BorderLayout,​ unlike //​java.awt.BorderLayout//,​ allows the setting of margins. Otherwiseit offers the usual regions: NORTH, WEST, EAST, SOUTH, and CENTER.
  
 FlowLayout offers the vertical and horizontal alignment of components, the use of margins, and it allows stretching as well as control of the alignment of the components within the layout. It basically supplements //​java.awt.FlowLayout//​ with additional functionality. FlowLayout offers the vertical and horizontal alignment of components, the use of margins, and it allows stretching as well as control of the alignment of the components within the layout. It basically supplements //​java.awt.FlowLayout//​ with additional functionality.
Line 17: Line 17:
 ==== FormLayout ==== ==== FormLayout ====
  
-As we can guess from the name, this layout manager is used for the creation of forms. However, it can also be used for a variety of other tasks. The basic idea behind this layout manager was to enable the creation of complex forms without ​using nesting or complexity.+As we can guess from the name, this layout manager is used for the creation of forms. However, it can also be used for a variety of other tasks. The basic idea behind this layout manager was to enable the creation of complex forms without nesting or complexity.
  
-The form layout ​works anchor-based. An anchor defines a position in the GUI and can be positioned using absolute references or relative references to another anchor.+The form layout ​is anchor-based. An anchor defines a position in the GUI and can be positioned using absolute references or relative references to another anchor.
  
-This allows, for example, ​subdividing ​a panel in table form, such as the //​java.awt.GridLayout//​. In addition, it can also be viewed as the //​java.awtGridBagLayout//​without the corresponding level of complexity.+This allows, for example, ​subdivision of a panel in table form, such as the //​java.awt.GridLayout//​. In addition, it can also be viewed as the //​java.awtGridBagLayout//​ without the corresponding level of complexity.
  
 The following examples illustrate the use of layout managers. The following examples illustrate the use of layout managers.
  
-== Simple ​example ​==+=== Simple ​Example ===
  
-A form containing ​columns (default setting):+A form containing ​two columns (default setting):
  
 {{:​jvx:​client:​gui:​form_2cols.png?​nolink|}} {{:​jvx:​client:​gui:​form_2cols.png?​nolink|}}
Line 55: Line 55:
 </​file>​ </​file>​
  
-The following call is sufficient to create 4 columns:+The following call:
  
 <file java> <file java>
 layout.setNewlineCount(4);​ layout.setNewlineCount(4);​
-</​file>​+</​file> ​ 
 + 
 +is sufficient to create four columns: 
 + 
 +{{:​jvx:​client:​gui:​form_4cols.png?​nolink|}} ​
  
-{{:​jvx:​client:​gui:​form_4cols.png?​nolink|}} +=== Complex ​Example ===
-== Complex ​example ​==+
  
 A somewhat more complex GUI is shown below: A somewhat more complex GUI is shown below:
Line 108: Line 111:
 </​file>​ </​file>​
  
-== Error dialog ​==+=== Error Dialog ===
  
-As a final example we want to show the framework´s error message, this time using a direct anchor:+As a final examplewe want to show the framework´s error message, this time using a direct anchor:
  
 {{:​jvx:​client:​gui:​form_dialog.png?​nolink|}} {{:​jvx:​client:​gui:​form_dialog.png?​nolink|}}
Line 142: Line 145:
                                               getLeftAnchor(),​ -5)));                                               getLeftAnchor(),​ -5)));
 </​file>​ </​file>​
 +\\ 
 +**<fs 20px>​Hint</​fs>​**
 +
 +There'​s a demo application which allows us to inspect the anchors of the FormLayout. The source code is [[https://​github.com/​sibvisions/​jvx.formlayout-visualization|hosted on github]].
 +
 +{{https://​github.com/​sibvisions/​jvx.formlayout-visualization/​raw/​master/​screenshots/​formlayout-visualization.png?​nolink}}
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information