swixml module

swixml module provides a function for GUI scripting with SwiXml.

renderSwixml (
( File | Reader | InputStream | URL | String | org.w3c.dom.Document | org.jdom.Document ) document
{ , Container container } )

renderSwixml() constructs a set of Swing components and layout them in the specified container. If container is not specified, components are added to a new javax.swing.JFrame object, which will become visible before this function returns.

Example 1

calculator.xml
<?xml version="1.0" encoding="UTF-8"?>
<frame name="mainframe" title="Calculator">
    <panel Bounds="10,10,150,150" Layout="FlowLayout" Visible="true" Resizable="true">
       <textfield id="t1" Columns="3" text=""/>
       <label text="+"/>
       <textfield id="t2" Columns="3" text=""/>
       <button id="btn" label="=" Action="add"/>
    </panel>
</frame>
renderSwixml(getFile("calculator.xml"))
function add(e) {
  t3.text = string(int(t1.text) + int(t2.text))
}

Example 2

pnutslayout.xml
<?xml version="1.0" encoding="UTF-8"?>
<frame name="mainframe" size="740,480" title="PnutsLayout example">
    <panel Bounds="10,10,150,150" Layout="PnutsLayout(cols=3)" Visible="true" Resizable="true">
      <button id="b1" Action="a1" constraints="colspan=2,valign=fill,halign=fill,expand=x">1</button>
      <button id="b2" Action="a2" constraints="rowspan=2,valign=fill,halign=fill,expand=y">2</button>
      <button id="b3" Action="a3" constraints="rowspan=2,halign=fill,valign=fill,expand=y">3</button>
      <button id="b4" Action="a4" constraints="colspan=2,halign=fill,expand=x">4</button>
    </panel>
</frame>
This example illustrates how to use PnutsLayout in swixml.