jlayout(1) - Linux man page
Name
jlayout - A Java code generator to create GUI elements
Synopsys
jlayout <inputfile> [<java-source>]
Description
The jlayout program reads a GUI description from the input file. The structure of the input file is explained below. The output operation is to modify a Java source code file. Regions of this file -- marked up by special comments -- are replaced by new code to create the GUI .
Options
- -h
issues a help text.
-v
prints version information.
Return Value
The program returns 0 on success, a positive value on exit.
Errors
There are two classes of errors: Syntax errors in the input file and processing errors while the program is running (i.e. not enought memory...)
Whenever applicable jlayout includes file name and line number of the object to which the error is related.
Diagnostics
Errors are reported to standard output or standard error output depending on the dklibs preferences set for logging.
Files
Input file
- General input file structure
The input file consists of a list of sections. Each section describes one GUI object. All sections -- except the first section -- are started by a section header. The section header contains the GUI objects class and variable name in square brackets. The first section is for the object class defined in the Java source code file, so it does not need a section header.
The remainder is a list of key/value pairs to set object attributes. Key and value are separated by ''=''.
In addition to normal lines there are control lines. Control lines are started by a dot. The can be used to set options for the jlayout program or to establish default values for some attributes.
Control lines
Option lines
- .option use tool tip text as accessible description = boolean
- For objects with no accessible description set we can choose whether or not to use the tool tip text as accessible description.
- Default lines
- .default fill = fill
- This is the default fill style used when no fill style is attached to an object. For fill styles see ''fill'' below.
- .default border = border
- This is the default for the space between objects in a container if not border attribute is attached to the container. For more information see ''border'' below.
- .default anchor = anchor
- This is the default anchor if no anchor attribute is attached to an object. For details see ''anchor'' below.
- attributes
- enabled = boolean
- enables or disables an object.
- layout = layout
- chooses a layout manager for the current object. Use one of the following: ''GridBag'', ''Card'', ''Border'', ''Box.X_AXIS'', ''Box.Y_AXIS'',
''Box.PAGE_AXIS'', ''Box.LINE_AXIS'', ''Flow'' or ''Grid''.
SpringLayout and GroupLayout can not be used.
- border = border
- specifies the space between objects in a container.
NOTE: This is not the space around the current component but the space between contents objects in the current object (the current object is a container).
The border must be a Java-int-expression.
- use content pane = boolean
- specifies whether to add contents objects directly to the current object (false) or to the content pane returned by getContentPane() (true).
- contents = object and placement
- adds a contents object to the current object (the current object is a container). Some layout managers require placement information after the object name.
Placement information format depends on the layout manager used by the current object:
- GridBag
start column, start row, width, height, anchor and fill. Anchor and fill information is optional, see below for an explaination. Start column and row can be specified directly (numeric values) or relative to the previous object:
- .
Use the same column/row number as for the previous object.
+n
From the start position of the previous object move n columns to the right / rows downwards.
-n
From the start position of the previous object move n columns to the left / rows upwards.
Card
A Java-String-expression returning a string which
- can be used to activate a card. If the placement information is ommited, jlayout creates a string from the number of the current object.
- Border
One of the anchors: '' PAGE_START '', '' LINE_START '', '' CENTER '', '' LINE_END '' or '' PAGE_END ''.
- Box..., Flow and Grid
- No placement information is necessary. Objects are added to the container in order of appearance in the input file.
- For Box... and Flow one can add the special object $glue to add horizontal or vertical glue (depending on the direction of the BoxLayout.
- GridBag
- fill = fill
- specifies how an object can grow if there is more room available than needed. Use ''none'', ''horizontal'', ''vertical'' or ''both'' for ''The object is not allowed to grow.'', ''The object is allowed to grow horizontally.'', ''...vertically.'' or ''... in both directions.''.
- anchor = anchor
- specifies where to place in object if there is more room available than used by the object. Use one of the following directions: '' NORTH '', '' NORTHWEST '', '' WEST '', '' SOUTHWEST '', '' SOUTH '', '' SOUTHEAST '', '' EAST '', '' NORTHEAST '' or '' CENTER ''.
- text = text
- specifies the text for all GUI elements showing text (i.e. labels, buttons...).
- icon file name = name
- specifies the file name of an icon to show.
- tool tip text = text
- specifies the tool tip text.
- accessible description = text
- specifies the text for the accessible description.
- title = text
- specifies the title for the JFrame, JDialog or JApplet).
- constructor = arg(s)
- specifies the function arguments passed to the objects constructor. For some objects jlayout automatically chooses one of the appropriate attributes as constructor if the constructor attribute is not specified.
- width = width
- specifies the width of a text field in characters.
- horizontal alignment = alignment
- specifies the horizontal text alignment, one of: ''leading'', ''left'', ''center'', ''right'' or ''trailing''.
- vertical alignment = alignment
- specifies the vertical text alignment, on of: ''top'', ''center'' or ''bottom''.
- size group = identifier
- specifies the name of a size group. Specify the same name here for all objects which must have the same size.
- button group = identifier
- specifies the ButtonGroup for radio buttons.
- component border = border
- specifies how to render the border of a component:
- empty
Draw an empty border.
- etched subtype
- Draw an etched border, either ''lowered'' or ''raised''.
- bevel subtype
- Draw a bevel border, either ''lowered'' or ''raised''.
- line
Draw a line.
- matte matte-type
- Draw either a solid color (''color:color'') or a tile pattern using an icon (''icon:filename'').
- titled text
- Draw a border and place a text label.
- empty
- minimum size = w h
- specifies the minimum size (numeric values).
- preferred size = w h
- specifies the preferred size (numeric values)
- maximum size = w h
- specifies the maximum size (numeric values).
- action command = text
- specifies the additional information text for the action event.
- action listener = listener
- item listener = listener
window listener = listener
caret listener = listener
change listener = listener
component listener = listener
container listener = listener
document listener = listener
focus listener = listener
internal frame listener = listener
key listener = listener
list data listener = listener
list selection listener = listener
mouse listener = listener
mouse motion listener = listener
mouse wheel listener = listener
property change listener = listener
table model listener = listener
tree expansion listener = listener
tree model listener = listener
tree selection listener = listener
tree will expand listener = listener
undoable edit listener = listener
specify event listeners for various event types. Use a variable name for a variable containg an object which already exists.
This name is used twice, once in jLayoutSetup() and once in jLayoutCleanup().
- transfer handler = handler
- specifies the transfer handler.
- default close operation = operation
- specifies how to hande a window closing event. Use one of ''nothing'', ''hide'', ''dispose'' or ''exit''.
- contents border = border
- specifies the space between objects in sub-containers of the current container.
- contents fill = fill
- specifies how to fill objects in sub-containers of the current container.
- contents anchor = anchor
- specifies the anchor position for objets in sub-containers of the current container.
Java source file
- The Java source code file must contain special comments to mark the regions to be replaced by jlayout.
- Variables
- Use // jlayout.variables.begin ... // jlayout.variables.end to mark the region for variables.
- Setup function
- Use // jlayout.setup.begin ... // jlayout.setup.end to mark the region for the jLayoutSetup() function.
- Cleanup function
- Use // jlayout.cleanup.begin ... // jlayout.cleanup.end to mark the region for the jLayoutCleanup() function.
Examples
Input file example inputjl
-
.default border = 2 .default fill = none .default anchor = west border = 2 fill = none title = "jlayout" layout = border menu bar = mb default close operation = dispose contents = pa center [JPanel pa] component border = titled "Panel" layout = gridbag contents = la1 0 0 1 1 west contents = cb1 1 0 1 1 west contents = paBu 0 1 2 1 center [JLabel la1] text = "Label" [JCheckBox cb1] text = "Checkbox" [JPanel paBu] layout = box.line_axis contents = bu1 contents = bu2 [JButton bu1] text = "Button 1" action listener = this tool tip text = "Exit this application" size group = sg1 [JButton bu2] text = "Button 2" action listener = this tool tip text = "Exit this application" size group = sg1 [JMenuBar mb] contents = mMenu [JMenu mMenu] text = "Menu" contents = miItem [JMenuItem miItem] text = "Item" action listener = this tool tip text = "Exit this application"
Java source code file example LogoWindowMain.java
-
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowEvent; import java.awt.Container; import java.awt.BorderLayout; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; import java.awt.Color; import java.awt.Dimension; import javax.swing.WindowConstants; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ImageIcon; import javax.swing.JPanel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.JCheckBox; public class LogoMainWindow extends JFrame implements ActionListener { // jlayout.variables.begin // jlayout.variables.end // jlayout.setup.begin // jlayout.setup.end // jlayout.cleanup.begin // jlayout.cleanup.end public LogoMainWindow() { super(""); jLayoutSetup(); } public void actionPerformed(ActionEvent e) { WindowEvent we = new WindowEvent( this, WindowEvent.WINDOW_CLOSING ); processWindowEvent(we); } }
How to run jlayout
-
jlayout input.jl MyFrame.java
Environment
There are no special environment for jlayout. Like other dklibs-based applications jlayout uses the LANG environment variable to find the language for log messages.
Restrictions
The SpringLayout and GroupLayout layout managers are not supported.
See Also
http://dktools.sourceforge.net/jlayout.html
Author
Dirk Krause
Copyright And License
Copyright © - 2008, Dirk Krause All rights resrved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Dirk Krause nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .