API for miglayout
(1.1.x branch)
by
Stephen C. Gilardi
Usage:
(ns your-namespace
(:require clojure.contrib.miglayout))
Overview
Clojure support for the MiGLayout layout manager
http://www.miglayout.com/
Example:
(use '[clojure.contrib.miglayout.test :as mlt :only ()])
(dotimes [i 5] (mlt/run-test i))
Public Variables and Functions
components
function
Usage: (components container)
Returns a map from id (a keyword) to component for all components with
an id constraint set
Source
miglayout
function
Usage: (miglayout container & args)
Adds java.awt.Components to a javax.swing.JComponent with constraints
formatted for the MiGLayout layout manager.
Arguments: container [item constraint*]*
- container: the container for the specified components, its layout
manager will be set to a new instance of MigLayout
- an inline series of items and constraints--each item may be followed
by zero or more constraints.
Item:
- An item is either a Component or one of the keywords :layout
:column or :row. Constraints for a keyword item affect the entire
layout.
Constraint: string, keyword, vector, map, or set
- A string specifies one or more constraints each with zero or more
arguments.
- A keyword specifies a single constraint without arguments
- A vector specifies a single constraint with one or more arguments
- A map specifies one or more constraints as keys, each mapped to a
single argument
- A set groups two or more constraints, each a string, keyword,
vector, map, or set
Any items marked with an "id" constraint will be included in a map from
id to component attached to the container. The map can be retrieved using
clojure.contrib.miglayout/components.
Source
miglayout.example
converter-ui
function
Usage: (converter-ui)
Lays out and shows a Temperature Converter UI
Source
fahrenheit
function
Usage: (fahrenheit celsius)
Converts a Celsius temperature to Fahrenheit. Input and output are
strings. Returns "input?" if the input can't be parsed as a Double.
Source
main
function
Usage: (main)
Invokes converter-ui in the AWT Event thread
Source
miglayout.internal
add-components
function
Usage: (add-components container components)
Adds components with constraints to a container
Source
component?
function
Usage: (component? x)
Returns true if x is a java.awt.Component
Source
constraint?
function
Usage: (constraint? x)
Returns true if x is not a keyword-item or component
Source
do-layout
function
Usage: (do-layout container layout column row components)
Attaches a MigLayout layout manager to container and adds components
with constraints
Source
function
Usage: (format-constraint c)
Returns a vector of vectors representing one or more constraints
separated by commas. Constraints may be specified in Clojure using
strings, keywords, vectors, maps, and/or sets.
Source
function
Usage: (format-constraints & constraints)
Returns a string representing all the constraints for one keyword-item
or component formatted for miglayout.
Source
get-components
function
Usage: (get-components container)
Returns a map from id to component for all components with an id
Source
parse-component-constraint
function
Usage: (parse-component-constraint constraint)
Parses a component constraint string returning a CC object
Source
parse-item-constraints
function
Usage: (parse-item-constraints & args)
Iterates over args and builds a map containing values associated with
:keywords and :components. The value for :keywords is a map from keyword
items to constraints strings. The value for :components is a vector of
vectors each associating a component with its constraints string.
Source
miglayout.test
label
function
Usage: (label text)
Returns a swing label
Source
sep
function
Usage: (sep)
Returns a swing separator
Source
text-field
function
Usage: (text-field)
(text-field width)
Returns a swing text field
Source