Rich Internet for Everyone (RICHIE) Network: United XAML - XUL Alliance - XUL News - XUL Forum - The Richmond Post - RichCon 2005
Open XUL Alliance Logo

Creating A Rich Internet For Everyone
Overview | XUL News Wire | XUL Interviews | XUL Polls | XUL Links | XForms Links | XUL Books | XUL Papers | XUL Events | XUL Meetup | XUL Forum | XUL Wiki | XUL Bloggers | XUL Challenge 2004 | The Richmond Post | Download | Sourceforge Project

XUL Grand Coding Challenge 2004 - Counter Sample Showcase

Counter Sample Showcase

Challenge #1 is a simple counter. Pressing the "Inc" button increments the counter (value), pressing the "Dec" button decrements it, and pressing "Clear" returns the counter (value) to zero. That's it.

Note, if you want to see the full monty, that is, all code-behind sources, scripts, readme docs and more grab a copy of the xul-challenge-2004 package (~800k) or browse the CVS repository online.

Luxor In Action - Counter Example

<xul>
  <vbox id="COUNTER">
   <groupbox>
     <caption label="Counter"/>
     <textbox id="DISPLAY" 
           style="align: center; color: yellow; background: black; font: 24 bold monospace;" />
   </groupbox>
   <hbox>
     <button label="Dec (-)"  command="dec"   style="width: 90px" />
     <button label="Clear"    command="clear" style="width: 90px" />
     <button label="Inc (+)"  command="inc"   style="width: 90px" />
   </hbox>
  </vbox>
</xul>
MyXaml in Action - Counter Example

<MyXaml>
  <Form Name="AppMainForm"
        Text="XUL Challenge 2004"
        StartPosition='CenterScreen'
        Size="256, 144"
        FormBorderStyle="FixedSingle">
    <Style def:Name="ButtonStyle">
      <StyleProperties>
	    <PropertyStyle FlatStyle="System"/>
	    <PropertyStyle Size="72, 25"/>
      </StyleProperties>
    </Style>
    <Controls>
      <GroupBox Name="GroupBox1" Text="Counter" Location="8, 8" Size="232, 96" FlatStyle="System">
        <Controls>
          <TextBox Name="TextBox1"
                   Text="0" 
                   Location="8, 24" 
                   Size="216, 23" 
                   TextAlign="Center" 
                   BackColor="Black" 
                   ForeColor="Yellow" 
                   Font="Microsoft Sans Serif, 10pt, style=Bold"/>
          <Button Name="Button1" Text="Dec(-)" Location="8, 56" Style="{ButtonStyle}" Click="OnDec"/>
          <Button Name="Button2" Text="Clear" Location="80, 56" Style="{ButtonStyle}" Click="OnClear"/>
          <Button Name="Button3" Text="Inc(+)" Location="152, 56" Style="{ButtonStyle}" Click="OnInc"/>
        </Controls>
      </GroupBox>
    </Controls>
  </Form>
</MyXaml>
Jazilla in Action - Counter Example

<window title="Xul Challenge 2004 Counter Example">
  <script type="text/javascript">
    var current = 0; // Start off with a default of 0
    function update() {
      var display = document.getElementById("DISPLAY");
      display.setAttribute("value", current.toString());
    }
  </script>
  <vbox id="COUNTER">
    <groupbox>
       <caption label="Counter"/>
       <textbox id="DISPLAY" disabled="true" value="0"/>
    </groupbox>
    <hbox>
      <button label="Dec (-)"  command="dec"   style="width: 90px" 
          oncommand="current = current - 1; update();"/>
      <button label="Clear"    command="clear" style="width: 90px" 
          oncommand="current = 0; update();"/>
      <button label="Inc (+)"  command="inc"   style="width: 90px" 
          oncommand="current = current + 1; update();"/>
    </hbox>
  </vbox>
</window>
xWidglets in Action - Counter Example

<window name="COUNTER" width="353" height="147" x="258" y="206" 
  QuitOnClose="true" PosAndSize="true" Tiled="false" BackgroundColor="F9F9F0" 
  border="Standard" titlebar="true" title="COUNTER">
  <Properties>
   <Class value="Window"/>
   <Description value=""/>
   <Events>
     <INIT><![CDATA[
       var control = new SysControl() ;
       var win = control.getWindow("COUNTER");
       var entry = control.getWidget(win,"ENTRYFIELD00001");
       entry.setText("0");
       var inc=0
       inc++;]]>
     </INIT>
   </Events>
   <MenuBar show="false"/>
  </Properties>

  <Controls>
   <Button Text="Clear" name ="BUTTON00003" number ="3" width ="103" 
     height ="23" x ="118" y ="71" opaque="true" contentAreaFilled="true" 
     fontName="Comic Sans MS" fontSize="16" fontStyle="plain" hPosText="0" 
     vPosText="0">
     <Events>
       <EXECUTED><![CDATA[
         inc=0;
         entry.setText(inc);]]>
       </EXECUTED>
     </Events>
   </Button>
   <Button Text="(+) INCR " name ="BUTTON00002" number ="2" width ="105" 
     height ="23" x ="223" y ="71" foreground="000000" opaque="true" 
     contentAreaFilled="true" fontName="Comic Sans MS" fontSize="16" 
     fontStyle="plain" hPosText="0" vPosText="0" Gradient="true" GradientType="6" 
     GradientForm="HORIZONTAL" GradientFirst="3333FF" GradientSecond="FFFFFF">
     <Events>
       <EXECUTED><![CDATA[         
         entry.setText(++inc);]]>
       </EXECUTED>
     </Events>
   </Button>
   <GroupBox text="Counter" name ="GROUPBOX00001" number ="1" width ="326" 
     height ="102" x ="8" y ="2" fontName="SansSerif" fontSize="12" 
     fontStyle="plain" foreground="003333" background="FFFFFF" opaque="false" 
     justification="3" />
   <Button Text="DECR (-)" name ="BUTTON00001" number ="1" width ="101" 
     height ="23" x ="15" y ="71" opaque="true" contentAreaFilled="true" 
     fittosize="true" fontName="Comic Sans MS" fontSize="16" fontStyle="plain" 
     hPosText="0" vPosText="0" Gradient="true" GradientType="5" 
     GradientForm="HORIZONTAL" GradientFirst="0000FF" GradientSecond="FFFFFF">
     <Events>
       <EXECUTED><![CDATA[
         entry.setText(--inc);]]>
       </EXECUTED>
     </Events>
   </Button>
   <EntryField  name ="ENTRYFIELD00001" number ="1" width ="311" height="44" 
     x="16" y="22" NumberOfCharacters="55" fontName="Arial" 
     fontSize="38" fontStyle="plain" justification="0" type="0" lockText="true" 
     controlTab=" " locale="FR" foreground="00CCCC" background="000000"/>
  </Controls>
</window>
XMLFace in Action - Counter Example

Swing UI: (Java)

Eclipse UI: (Java)

Windows Forms UI (.Net/C#)

<xface:application
	xmlns:xface="http://www.xesoft.com/xmlns/xface"
	xmlns:counter="http://www.xesoft.com/xmlns/examples/counter"
	id="counter"
	bundle="application">

	<xface:window id="main" width="300" height="110" label="counter">

		<!-- Define the panel layout scheme to be used -->
		<xface:relative-layout constraints="main.layout.properties"/>

		<!-- Define the controls to be added to the panel -->
		<xface:label id="label_count"/>
		<xface:text-input id="count" defaultValue="0" editable="false"/>

		<xface:button id="decrease"/>
		<xface:button id="clear"/>
		<xface:button id="increase"/>

		<!-- Define the logic / event handlers related to the window -->
		<xface:show-adapter element="../.." event="STARTUP"/>
		<xface:exit-adapter element=".." event="CLOSE"/>
		<counter:logic-handler/>

	</xface:window>

</xface:application> 
label_count.left=_container.left+10
label_count.verticalCenter=count.verticalCenter

count.top=_container.top+10
count.left=label_count.right+5
count.right=_container.right-10

decrease.left=_container.left+10
decrease.bottom=_container.bottom-10
decrease.top=count.bottom+10

increase.right=_container.right-10
increase.bottom=_container.bottom-10
increase.top=count.bottom+10

clear.right=increase.left-10
clear.left=decrease.right+10
clear.bottom=_container.bottom-10
clear.top=count.bottom+10
counter=Counter
label_count=Count:
decrease=Dec (-)
increase=Inc (+)
clear=Clear
Ultrid in Action - Counter Example

<ultrid context="/ultrid/" path="counter/">
    <jframe id="frame" title="Ultrid Counter" 
            default-close-operation="exit-on-close" resizable="false">
        <jpanel layout="vbox">
            <compound-border>                
                <empty-border thickness="12"/>
                <titled-border title="Counter"/>
            </compound-border>
            <jpanel layout="vbox">
                <empty-border thickness="12"/>
                <jpanel layout="border">
                    <bevel-border border-type="lowered" soft-corners="true"/>
                    <jtextfield id="counter-texfield" constraint="center" text="0" 
                        horizontal-alignment="center" background="black" 
                        foreground="yellow" editable="false"
                        font="Arial, Bold, 14">
                        <on-key method="typed" language="javascript" source="key-typed.js"/>
                    </jtextfield>
                </jpanel>
                <filler length="17"/>
                <jpanel layout="hbox">
                    <jbutton text="_Dec(-)" js-param="-">
                        <on-key method="typed" language="javascript" source="key-typed.js"/>
                        <on-mouse method="released" language="javascript" source="count.js"/>
                    </jbutton>
                    <filler length="5"/>
                    <jbutton text="_Clear" js-param="c">
                        <on-key method="typed" language="javascript" source="key-typed.js"/>
                        <on-mouse method="released" language="javascript" source="count.js"/>
                    </jbutton>
                    <filler length="5"/>
                    <jbutton text="_Inc(+)" js-param="+">
                        <on-key method="typed" language="javascript" source="key-typed.js"/>
                        <on-mouse method="released" language="javascript" source="count.js"/>
                    </jbutton>
                </jpanel>
            </jpanel>                       
        </jpanel>                       
        <laf.manager look-and-feel="System" component-ref="frame"/>
    </jframe>
</ultrid>
FormsPlayer in Action - Counter Example (W3C XForms)

<html
 xmlns:xforms="http://www.w3.org/2002/xforms"
 xmlns="http://www.w3.org/1999/xhtml">
  <head>

    <object id="formsPlayer" classid="CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58">
      <b>formsPlayer has failed to load! Please check your installation.</b>
      <br />
    </object>

    <?import NAMESPACE="xforms" IMPLEMENTATION="#formsPlayer" ?>

    <title>XUL Challenge - Counter Example - formsPlayer</title>

    <xforms:model>
      <xforms:instance>
        <counter xmlns="">0</counter>
      </xforms:instance>
    </xforms:model>

    <style>
     body
     {
      font-family: "Trebuchet MS", Verdana, Helvetica, sans-serif;
     }
     xforms\:trigger { cursor: hand; }
     xforms\:hint { width: 200px; }
    </style>
  </head>
  <body>

    <xforms:output ref="/counter" style="width: 240px; color: yellow; background-color: black; font: 24 bold monospace;" />
    <hr />
    <xforms:trigger>
	<xforms:label>Dec (-)</xforms:label>
	<xforms:setvalue ev:event="DOMActivate" ref="/counter" value=". - 1" />
	<xforms:hint>Subtract one from the counter value (the result will be '<b><xforms:output value=". - 1" /></b>')</xforms:hint>
    </xforms:trigger>

    <xforms:trigger>
	<xforms:label>Clear</xforms:label>
	<xforms:hint>Set the counter back to zero</xforms:hint>
	<xforms:setvalue ev:event="DOMActivate" ref="/counter">0</xforms:setvalue>
    </xforms:trigger>

    <xforms:trigger>
	<xforms:label>Inc (+)</xforms:label>
	<xforms:setvalue ev:event="DOMActivate" ref="/counter" value=". + 1" />
	<xforms:hint>Add one to the counter value (the result will be '<b><xforms:output value=". + 1" /></b>')</xforms:hint>
    </xforms:trigger>
  </body>
</html>

Xoetrope XUI in Action - Counter Example

<XPage class="com.xoetrope.controls.swing.Welcome">
  <Components>
    <Label x="10" y="10" w="48" h="20" content="Caption:" alignment="Left" opaque="true"/>
    <Edit name="Counter" x="60" y="10" w="176" h="20" alignment="Leading"/>
    <Panel x="10" y="40" w="225" h="20" layout="border">
      <Button name="DecBtn" content="Dec (-)" constraint="west"/>
      <Button name="ClearBtn" content="Clear" constraint="center"/>
      <Button name="IncBtn" content="Inc (+)" constraint="east"/>
    </Panel>
  </Components>
  <Events>
    <Event method="decrement" target="DecBtn" type="ActionHandler"/>
    <Event method="clear" target="ClearBtn" type="ActionHandler"/>
    <Event method="increment" target="IncBtn" type="ActionHandler"/>
  </Events>
  <Data>
    <Bind target="Counter" source="counterValue" output="counterValue"/>
  </Data>
</XPage>
Flex in Action - Counter Example (Macromedia Flash)

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
  <mx:Number id="counter">0</mx:Number>
  <mx:Style>
      TextInput {
        font-family: monospace;
        font-size: 24pt;
        font-weight: bold;
        color:#ffff00;
        backgroundColor:#000000;
      }
  </mx:Style>
  <mx:Panel title="Counter">
    <mx:TextInput text="{counter}" textAlign="center" widthFlex="1"/>
    <mx:HBox>
      <mx:Button label="Dec(-)" click="counter--" widthFlex="2"/>
      <mx:Button label="Clear" click="counter = 0" widthFlex="1"/>
      <mx:Button label="Inc(+)" click="counter++" widthFlex="2"/>
    </mx:HBox>
  </mx:Panel>
</mx:Application>
SwiXml in Action - Counter Example

<frame Title="XUL Challenge 2004">
  <panel Layout="BorderLayout" Border="TitledBorder(Counter)">
    <panel>
      <formattedtextfield id="ftf" Columns="20" Value="0" 
         Editable="false" Background="black" Foreground="yellow"/>
    </panel>
    <panel constraints="BorderLayout.SOUTH">
      <button Text="Dec (-)" Action="inc" ActionCommand="-1"/>
      <button Text="Clear" Action="clr"/>
      <button Text="Inc (+)" Action="inc" ActionCommand="1"/>
    </panel>
  </panel>
</frame>
Avalon XAML in Action - Counter Example

<Window
   xmlns=http://schemas.microsoft.com/2003/xaml
   xmlns:def="Definition" def:Class="CounterSample.Counter"
   def:CodeBehind="Counter.xaml.cs"
   Text="Xul Challenge 2004"
   Visible="True"
   Width="268"
   Height="150"
   Loaded="OnLoaded">
<Window.Resources>
   <Style>
      <Button Margin="5" FontSize="14" />
   </Style>
</Window.Resources>
<FlowPanel>
   <FlowPanel.Background>
      <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
         <LinearGradientBrush.GradientStops>
            <GradientStop Color="#E7E7E7" Offset="0" />
            <GradientStop Color="#FFFFFF" Offset="0.02" />
            <GradientStop Color="#FFF287" Offset="0.2" />
            <GradientStop Color="#F9E11A" Offset="0.98" />
            <GradientStop Color="#000000" Offset="1" />
         </LinearGradientBrush.GradientStops>
      </LinearGradientBrush>
   </FlowPanel.Background>
   <SimpleText Margin="5" FontSize="14">Counter Sample</SimpleText>
   <TextBox ID="ValueTextBox" FontSize="14" Width="250" Height="30" 
      HorizontalAlignment="Center" IsReadOnly="True" Margin="5"></TextBox>
   <FlowPanel HorizontalAlignment="Center" Width="100%">
      <Button Click="Dec">Dec (-)</Button>
      <Button Click="Clear">Clear</Button>
      <Button Click="Inc">Inc (+)</Button>
   </FlowPanel>
</FlowPanel>
</Window>
Beryl in Action - Counter Example

<UI version="1.0">
  <widget name="Counter" class="Frame">
    <property name="size" type="dimension">
      <width>300</width>
      <height>100</height>
    </property>
    <property name="visible" type="bool">true</property>
    <property name="title" type="istring">counter.title</property>
    <property name="defaultCloseOperation" type="enum">exit</property>
		
    <property name="border" type="border" border="titled">
      <title>counter.counter</title>
    </property>

    <widget class="Panel">
      <layout type="vbox"/>
      <property name="spacing" type="int">5</property>

      <widget class="TextField">
        <property name="background" type="color">#000000</property>
	<property name="foreground" type="color">#ffff00</property>
	<property name="horizontalAlignment" type="enum">center</property>
	<property name="font" type="font">
	  <name>Monospaced</name>
	  <style>bold</style>
	  <size>24</size>
	</property>
	<property name="key">number</property>
	<property name="editable" type="bool">false</property>
      </widget>

      <widget class="Panel">
	<layout type="flow"/>
	<widget class="Button">
	  <property name="text">counter.dec</property>
	  <emit event="clicked" name="dec"/>
	</widget>
	<widget class="Button">
	  <property name="text">counter.clear</property>
	  <emit event="clicked" name="clear"/>
	</widget>
	<widget class="Button">
	  <property name="text">counter.inc</property>
	  <emit event="clicked" name="inc"/>
	</widget>
      </widget>
    </widget>
  </widget>
</UI>
counter.title=XUL Challenge 2004 Counter
counter.counter=Counter
counter.inc=Increase
counter.dec=Decrease
counter.clear=Clear
Purnama XUI in Action - Counter Example

<xui:XUI xmlns:xui="http://xml.bcit.ca/PurnamaProject/2003/xui"    
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
  xsi:schemaLocation="http://xml.bcit.ca/PurnamaProject/2003/xui ./xui.xsd" 
  id="http://geekkit.bcit.ca/counter">
  <xui:Window id="window_0" name="XUL Challenge 2004" x="100" y="100" width="250" height="110" visible="true">
    <xui:GridLayout width="1" height="1"></xui:GridLayout>
    <xui:Panel x="0" y="0" width="1" height="1" id="panel_0" name="panel" idref="window_0">
      <xui:GridLayout width="3" height="4"></xui:GridLayout>
      <xui:Label x="0" y="0" width="3" height="1" text="Counter" justified="left" id="label_0"/>
      <xui:TextField x="1" y="0" width="3" height="1" enabled="true" id="textfield_0">
        <xui:Text>34</xui:Text>
      </xui:TextField>
      <xui:Button id="button_0" width="1" height="1" enabled="true" 
      orientation="horizontal" x="2" y="0" label="Dec (-)"></xui:Button>
      <xui:Button id="button_1" width="1" height="1" enabled="true" 
      orientation="horizontal" x="2" y="1" label="Clear"></xui:Button>
      <xui:Button id="button_2" width="1" height="1" enabled="true" 
      orientation="horizontal" x="2" y="2" label="Inc (+)"></xui:Button>
    </xui:Panel>
  </xui:Window>
</xui:XUI>
Xamlon in Action - Counter Example

<?Mapping XmlNamespace="wf" ClrNamespace="System.Windows.Forms" Assembly="System.Windows.Forms" ?> 
<?Mapping XmlNamespace="wfi" ClrNamespace="Xamlon.Windows.Forms.Integration" Assembly="Xamlon"?>
<?Mapping XmlNamespace="xf" ClrNamespace="Xamlon.Windows.Forms" Assembly="Xamlon" ?>
<?Mapping XmlNamespace="events" ClrNamespace="Counter" Assembly="Counter" ?>

<Window
    xmlns="http://schemas.microsoft.com/2003/xaml"
    xmlns:def="Definition"
    xmlns:wfi="wfi"
    xmlns:wf="wf"
    xmlns:xf="xf"
    def:Class="Counter.CounterEvents"
    Width="453" Height="253"
    FormBorderStyle="FixedToolWindow"
    Text="Xamlon Counter Example"
    >

    <Canvas Width="100%" Height="100%">
    ...	
    <Path Fill="Black"
       Data="M38.68,70.38H24.07l19.26-22.82L25.05,25.59h14.71l10.67,14.56l10.94-14.56
	     h14.63L57.72,47.2l19.4,23.19H61.98 l-11.3-15.21L38.68,70.38z"/>
    <Polygon Fill="#FF9900" Points="35.1,48.04 19.43,63.71 19.43,32.36 "/>
    <SimpleText Canvas.Left="75" Canvas.Top="37"
	Foreground="White" FontSize="20">COUNTER</SimpleText>

    <Rectangle
	Opacity="0.64"
	Canvas.Left="13" Canvas.Top="96"
	Width="420" Height="60"
	RadiusX="25" RadiusY="25"
	Fill="{OuterBorder}"/>
    <Rectangle
	Canvas.Left="18" Canvas.Top="101"
	Width="410" Height="50"
	RadiusX="22" RadiusY="22"
	Fill="#CACFB5" Stroke="VerticalGradient #6B6E60 #9DA18F" StrokeThickness="2"/>

    <SimpleText ID="count" FontFamily="Arial" FontSize="30" HorizontalAlignment="Center" 
	Width="410" Canvas.Left="18" Canvas.Top="110">0</SimpleText>
		
    <wfi:WindowsFormsHost ID="wfh" Width="325" Height="35"
	Canvas.Left="75" Canvas.Top="172" Background="255,153,0">
	<wfi:WindowsFormsHost.Controls>
  	  <xf:FlowPanel Width="325">
	    <wf:Button Width="100" Height="30" Text="Dec(-)" Font="Arial, 14" Click="OnClick" />              
            <wf:Button Width="100" Height="30" Text="Clear" Font="Arial, 14" Click="OnClick" />
      	    <wf:Button Width="100" Height="30" Text="Inc(+)" Font="Arial, 14" Click="OnClick" />    	  
          </xf:FlowPanel>
	</wfi:WindowsFormsHost.Controls>
    </wfi:WindowsFormsHost>

  </Canvas>
</Window>
Zeepe in Action - Counter Example (DHTML)

<HTML>
<HEAD>
<TITLE>Challenge 2004 - Counter</TITLE>
<zeepe:window>
	<window>
		<widgets dialog="true" />
		<position width="300" height="150" 
                     halign="middle" valign="middle" />
	</window>
</zeepe:window>
<style type="text/css">
body {
	overflow: hidden;
	border: none;
	padding: 0;
	background-color: buttonface;
	filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, 
		StartColorStr='#ffffff', 
		EndColorStr='#eeeeee');
}
button { width: 80; }
#counter {
	background-color: black;
	color: white;
	border: 1px inset;
	padding: 2px;
	margin: 4px;
	font-weight: bold;
}
</style>
<script language="javascript">
...
</script>
</HEAD>
<BODY>
<fieldset>
	<legend>Counter</legend>
	<div id="counter" align="center">0</div>
	<div align="center">
          <button onclick="dec()">Dec(-)</button>
          <button onclick="doclear()">Clear</button>
          <button onclick="inc()">Inc(+)</button>
        </div>
</fieldset>
</BODY>
</HTML>
Zulu in Action - Counter Example (Macromedia Flash)

<xul>
    <window bgColor="0xd4d0c8">
        <groupbox>
            <caption label="Counter"/>
            <vbox vgap="10">
                <textbox id="DISPLAY" value="99" readonly="true" cols="20"
                     style="text-align:center; color:yellow; background:black; 
                       font-size:13; font-family:monospace; font-weight:bold;"/>
                <hbox hgap="4">
                    <button label="Dec (-)" onClick="dec" style="width:68;"/>
                    <button label="Clear" onClick="clr" style="width:68;"/>
                    <button label="Inc (+)" onClick="inc" style="width:68;"/>
                </hbox>
            </vbox>
        </groupbox>
    </window>
    <command id="dec" target="DISPLAY">
        <function name="basic:dec">
            <id>DISPLAY</id>
        </function>
    </command>
    <command id="inc" target="DISPLAY">
        <function name="basic:inc">
            <id>DISPLAY</id>
        </function>
    </command>
    <command id="clr" target="DISPLAY">
        <function name="basic:clr">
        </function>
    </command>
</xul>
Keystone in Action - Counter Example

<svg min-width="320" min-height="100">
   <rect stroke="none" fill="white" x="5" y="5" width="310" height="90"/>
   <polygon stroke="none" fill="lightsteelblue" points="5,5 95,5 5,95"/>
   <polygon stroke="none" fill="blue" points="95,5 105,5 15,95 5,95"/>   
   <polygon stroke="none" fill="steelblue" points="105,5 115,5 25,95 15,95"/>      
   <rect stroke="grey" fill="none" x="5" y="5" width="310" height="90"/>
   <rect stroke="none" fill="black" x="10" y="15" width="300" height="30"/>   
   <text fill="lime" text-anchor="middle" x="160" y="39" font-weight="bold" font-family="Arial" font-size="24">0
      <bind attributeName="text" binding="/counter/@value"/>   
   </text>

   <g transform="translate(10,60)">
      <xul:hbox width="300" height="30">
         <xul:button label="Dec (-)" binding="/counter/@command=Dec"/>
         <xul:button label="Clear" binding="/counter/@command=Clear"/>
         <xul:button label="Inc (+)" binding="/counter/@command=Inc"/>
      </xul:hbox>
   </g>      
</svg>
Mozilla in Action - Counter Example

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="counter"
onload="document.getElementById('count').value=counter"
>
<script type="text/javascript">
<![CDATA[

var counter=0;

function increment(){
   counter++;
   document.getElementById('count').value=counter;
}
function decrement(){
   counter--;
   document.getElementById('count').value=counter;
}

function clear(){
   counter=0;
   document.getElementById('count').value=counter;
}

]]>
</script>
   <description>This is a simple counter</description>
   <groupbox>
     <caption label="Counter"/>
     <textbox id="count" readonly="yes" />
   </groupbox>
   <hbox pack="center">
     <button label="Dec (-)"  oncommand="decrement()"   />
     <button label="Clear"    oncommand="clear()" />
     <button label="Inc (+)"   oncommand="increment()"   />
   </hbox>

</window>
WiSer in Action - Counter Example

Swing UI

Web UI

<application port="8080" name="Counter/start" mdi="false" height="150" width="480">
    <xScript file = "THIS" exec = "declListeners">
        <Proc name = "declListeners">
          <Declare objname = "counter_li" objtype = "counter.listeners.Counter_li" objctx = "forever"/>
        </Proc>
    </xScript>    
    <page name="WiSer - XUL Challenge 2004 - Counter" active="true" scroll="false">
        <position x="0" y="0" height="150" width="480"/>
        <border name="Counter" scroll="false">
            <htmlLOM class="Jmc.webGui.html_gridBagLayout" insets="4"/>
            <position x="0" y="0" height="1" width="1" align="WEST"/>
            <form name="MyNewForm" scroll="false">
                <htmlLOM class="Jmc.webGui.html_gridBagLayout" insets="4"/>
                <position x="0" y="0" height="1" width="1" align="WEST"/>
                <label name="MyNewLabel" value="0" register="display">
                    <position x="0" y="0" height="1" width="1" align="CENTER"/>
                    <font name="Arial" style="bold" size="20"/>
                    <color fg="yellow"/>
                </label>
                <color bg="black"/>
                <weights weightX="100" weightY="50"/>
            </form>
            <form name="MyNewForm" scroll="false">
                <htmlLOM class="Jmc.webGui.html_gridBagLayout" insets="4"/>
                <position x="0" y="1" height="1" width="1" align="WEST"/>
                <button name="inc (+)">
                    <position x="0" y="0" height="1" width="1" align="CENTER"/>
                    <srvListener object = "counter_li"/>
                </button>
                <button name="reset">
                    <position x="1" y="0" height="1" width="1" align="CENTER"/>
                    <srvListener object = "counter_li"/>
                </button>
                <button name="dec (-)">
                    <position x="2" y="0" height="1" width="1" align="CENTER"/>
                    <srvListener object = "counter_li"/>
                </button>
                <weights weightX="100" weightY="50"/>
            </form>
        </border>
    </page>
</application>
Thinlet in Action - Counter Example

<panel text=" Counter " border="true" font="bold" columns="3"
    top="4" left="4" bottom="4" right="4" gap="4">
  <label name="label" text="0" alignment="center" colspan="3" weighty="1"
    background="#000000" foreground="#ffff00" font="monospaced bold 24" />
  <button text="Dec (-)" action="decrease(label)" />
  <button text="Clear" action="clear(label)" weightx="1" />
  <button text="Inc (+)" action="increase(label)" />
</panel>
UIML.NET in Action - Counter Example

<uiml>
  <interface>
    <structure>
      <part class="Frame" id="CounterFrame">
        <part class="VBox">
	  <part class="Entry" id="counterEntry"/>
	  <part class="HBox">
	    <part class="Button" id="dec"/>
	    <part class="Button" id="clear"/>
	    <part class="Button" id="inc"/>
  	  </part>
	</part>
      </part>
    </structure>
    <style>
      <property part-name="CounterFrame" name="label">Counter</property>
      <property part-name="dec" name="label">dec (-)</property>
      <property part-name="clear" name="label">clear</property>
      <property part-name="inc" name="label">inc (+)</property>
      <property part-name="counterEntry" name="text">0</property>
    </style>
    <behavior>
      <rule>
        <condition>
	  <event class="ButtonPressed" part-name="inc"/>
	</condition>				
	<action>
	  <property part-name="counterEntry" name="text">
	    <call name="MyMath.inc">
	      <param><property part-name="counterEntry" name="text"/></param>					  	    </call>	
	  </property>
	</action>
      </rule>
      ...
    </behavior>
  </interface>
  <peers>
    <presentation base="http://research.edm.luc.ac.be/kris/projects/uiml.net/gtk-sharp-1.0.uiml" />
    <logic id="mmath">
      <d-component id="MyMath" maps-to="MyMath">
  	<d-method id="inc" return-type="string" maps-to="Increment">
	  <d-param type="System.String"/>
	</d-method>
        <d-method id="dec" return-type="string" maps-to="Decrement">
	  <d-param type="System.String"/>
	</d-method>
      </d-component>
    </logic>
  </peers>
</uiml>
SourceForge Logo Please send comments on our web pages to our public xul-talk mailinglist or to a member of our web team. Copyright © 2003, 2004, 2005 Open XUL Alliance