Layout manager

Last updated

Layout managers are software components used in widget toolkits which have the ability to lay out graphical control elements by their relative positions without using distance units. It is often more natural to define component layouts in this manner than to define their position in pixels or common distance units, so a number of popular widget toolkits include this ability by default. Widget toolkits that provide this function can generally be classified into two groups:

Contents

Examples

Android have the ConstraintLayout. [1]

GTK have the Box [2] and Grid [3] classes.

XUL

In XUL, like the vbox container to stack components on top of each other.

<?xml version="1.0"?><?xml-stylesheet href="chrome://global/skin/" type="text/css"?><windowid="vbox example"title="Example"xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><vbox><buttonid="yes"label="Yes"/><buttonid="no"label="No"/><buttonid="maybe"label="Maybe"/></vbox></window>

This piece of code shows 3 buttons stacked on top of each other in a vertical box.

XAML

The DockPanel container lays out children components according to their Dock properties.

<Pagexmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"WindowTitle="myDock Panel"><DockPanel><TextBlockDockPanel.Dock="Top">Top1</TextBlock><TextBlockDockPanel.Dock="Top">Top2</TextBlock><TextBlockDockPanel.Dock="Top">Top3</TextBlock><TextBlockDockPanel.Dock="Top">Top4</TextBlock></DockPanel></Page>

This code shows 4 text blocks on top of each other.

Java

The FlowLayout layout manager arranges components in a directional flow, much like lines of text in a paragraph. It arranges components horizontally until no more components fit on the same line, then it places them on another line. Other layout managers are GridLayout managers which arrange the components in grid form and BorderLayout managers which also arranges the component in five parts of the frame, thus: south, north, west, east and center.

importjavax.swing.JFrame;importjavax.swing.JButton;importjava.awt.FlowLayout;importjava.awt.Container;publicclassExample{privateJFrameframe;publicExample(){frame=newJFrame("FlowLayout Demo");frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setLayout(newFlowLayout());frame.add((newJButton("Button 1")));frame.add((newJButton("Button 2")));frame.add((newJButton("Button 3")));frame.add((newJButton("Long-Named Button 4")));frame.add((newJButton("5")));frame.pack();frame.setVisible(true);}publicstaticvoidmain(String[]args){Exampleex=newExample();}}

This code shows 5 buttons alongside each other on the same line:

FlowLayoutDemo.gif

  1. "Build a responsive UI with ConstraintLayout | Views". Android Developers. Google. Retrieved 17 December 2024.
  2. "Gtk.Box". docs.gtk.org. Retrieved 17 December 2024.
  3. "Gtk.Grid". docs.gtk.org. Retrieved 17 December 2024.

Related Research Articles

XUL, which stands for XML User Interface Language, is a user interface markup language developed by Mozilla. XUL is an XML dialect for writing graphical user interfaces, enabling developers to write user interface elements in a manner similar to web pages.

<span class="mw-page-title-main">Swing (Java)</span> Java-based GUI toolkit

Swing is a GUI widget toolkit for Java. It is part of Oracle's Java Foundation Classes (JFC) – an API for providing a graphical user interface (GUI) for Java programs.

<span class="mw-page-title-main">Standard Widget Toolkit</span> Graphical widget toolkit for use with the Java platform

The Standard Widget Toolkit (SWT) is a graphical widget toolkit for use with the Java platform. It was originally developed by Stephen Northover at IBM and is now maintained by the Eclipse Foundation in tandem with the Eclipse IDE. It is an alternative to the Abstract Window Toolkit (AWT) and Swing Java graphical user interface (GUI) toolkits provided by Sun Microsystems as part of the Java Platform, Standard Edition (J2SE).

Extensible Application Markup Language is a declarative XML-based language developed by Microsoft for initializing structured values and objects. It is available under Microsoft's Open Specification Promise.

<span class="mw-page-title-main">Graphical widget</span> Element of interaction in a graphical user interface

A graphical widget in a graphical user interface is an element of interaction, such as a button or a scroll bar. Controls are software components that a computer user interacts with through direct manipulation to read or edit information about an application. User interface libraries such as Windows Presentation Foundation, Qt, GTK, and Cocoa, contain a collection of controls and the logic to render these.

<span class="mw-page-title-main">Fox toolkit</span>

The FOX toolkit is an open-source, cross-platform widget toolkit, i.e. a library of basic elements for building a graphical user interface (GUI). FOX stands for Free Objects for X.

wxPython Python wrapper for wxWidgets

wxPython is a wrapper for the cross-platform GUI API wxWidgets for the Python programming language. It is one of the alternatives to Tkinter. It is implemented as a Python extension module.

<span class="mw-page-title-main">Graphical user interface builder</span> Software development tool

A graphical user interface builder, also known as GUI designer or sometimes RAD IDE, is a software development tool that simplifies the creation of GUIs by allowing the designer to arrange graphical control elements using a drag-and-drop WYSIWYG editor. Without a GUI builder, a GUI must be built by manually specifying each widget's parameters in the source code, with no visual feedback until the program is run. Such tools are usually called the term RAD IDE.

Java TV is a Java-based software framework designed for use on TV set-top boxes, based on components called Xlets. It is currently used only on the Connected Device Configuration, specifically for iTV applications development.

The event dispatching thread (EDT) is a background thread used in Java to process events from the Abstract Window Toolkit (AWT) graphical user interface event queue. It is an example of the generic concept of event-driven programming, that is popular in many other contexts than Java, for example, web browsers, or web servers.

A user interface markup language is a markup language that renders and describes graphical user interfaces and controls. Many of these markup languages are dialects of XML and are dependent upon a pre-existing scripting language engine, usually a JavaScript engine, for rendering of controls and extra scriptability.

<span class="mw-page-title-main">Tkinter</span> Python binding to the Tk GUI toolkit

Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit, and is Python's de facto standard GUI. Tkinter is included with standard Linux, Microsoft Windows and macOS installs of Python.

BD-J, or Blu-ray Disc Java, is a specification supporting Java ME Xlets for advanced content on Blu-ray Disc and the Packaged Media profile of Globally Executable MHP (GEM).

The Internet Foundation Classes (IFC) is a GUI widget toolkit and graphics library for Java originally developed by Netcode Corporation and first released by Netscape Corporation on December 16, 1996.

java-gnome is a set of language bindings for the Java programming language for use in the GNOME desktop environment. It is part of the official GNOME language bindings suite and provides a set of libraries allowing developers to write computer programs for GNOME using the Java programming language and the GTK cross-platform widget toolkit.

<span class="mw-page-title-main">Abstract Window Toolkit</span> Java-based GUI toolkit

The Abstract Window Toolkit (AWT) is Java's original platform-dependent windowing, graphics, and user-interface widget toolkit, preceding Swing. The AWT is part of the Java Foundation Classes (JFC) — the standard API for providing a graphical user interface (GUI) for a Java program. AWT is also the GUI toolkit for a number of Java ME profiles. For example, Connected Device Configuration profiles require Java runtimes on mobile telephones to support the Abstract Window Toolkit.

JWt is an open-source widget-centric web application framework for the Java programming language developed by Emweb. It has an API that uses established GUI application development patterns. The programming model is component-based and event-driven, similar to Swing.

<span class="mw-page-title-main">Fyne (software)</span> Graphical toolkit for building cross platform GUIs

Fyne is a free and open-source cross-platform widget toolkit for creating graphical user interfaces (GUIs) across desktop and mobile platforms. It is designed to enable developers to build applications that run on multiple desktop and mobile platforms/versions from a single code base. Fyne uses OpenGL to provide cross-platform graphics. It is inspired by the principles of Material Design to create applications that look and behave consistently across all platforms. It is licensed under the terms of the 3-clause BSD License, supporting the creation of free and proprietary applications. In December 2019 Fyne became the most popular GUI toolkit for Go, by GitHub star count and in early February 2020 it was trending as #1 project in GitHub trending ranks.