|
Use XML to build fully interactive multi-page applications in a JAVA environment. Easily integrate your own JAVA programs with SmartWidgets. Seperate your interfaces from your program logic. Exploit the elagance of XML to define your interfaces. Build fully scalable interfaces. See our SampSonic SmartWidgets application. A revolutionary music and digital photo jukebox. |
![]() |
![]() |
The above panels are part of the SampSonic jukebox application. The following script is taken from the SmartWidgets XML script for that application:
Note that I have added JAVA style comments to the source to explain the tags.
<?xml version="1.0" encoding='ISO-8859-1'?>
<application Id='Sampsonic' ScriptVer='2.0' NetworkPath='http://www.tallpine.com/sampsonic'
xSize='1000' ySize='750' >
.
.
.
// Symbols are variables that can be passed between tags and to your JAVA application.
// They can have persistant values which are stored in JAVA ini files.
<symbol id='frame' save='yes' default='yes' value='true'/>
<symbol id='width' save='yes' default='yes' value='800'/>
<symbol id='height' save='yes' default='yes' value='600'/>
// All widgets are displayed in areas. Areas can be relative to other areas.
// A grid is a two dimensional array of areas.
// All content in an area scales as the main JAVA panel containing the plates are resized.
<Grid Id='SelectBtns' relto='SelectBar' xPos='0' yPos='0' xext='1000' yext='1000'
rows='10' cols='1' iborder='20' oborder='4' />
// Events are used to communicate action to other widgets and to your application.
// Your application sees these events using the standard JAVA event model.
<event id='readinput' />
// Commands are similar to events but can pass additional information to the command handler.
<command id='REMOVECDVOLUMES' list='cdselectedVolumes' code='2' parms='remove cd volumes' />
// A list is a standard named-object in SmartWidgets. They are used for comboboxes and listboxes.
// Your application can set the values in a list.
<list id=boolean>
<item label='Yes' value='true' />
<item label='No' value='false' />
</list>
// An important feature of SmartWidgets is the ability to define macros that let you build a custom
// set of tags that are specific to your application. A macro tag can be used repeatedly to
// build a custom set of widgets on your plates (pages). A macro is expanded each time it is invoked.
<macrodef id='button'>
// The essential presentation element of any SmartWidgets application is the Widget.
// Widgets are state machines which are driven by the XML attributes in the tag.
// Typically a widget has two states, 'ON' and 'OFF'. The state is changed by
// catching an event or by receiving a mouse click. Each state transition can result
// in a series of actions being performed and has a set of painting
// instructions defined by a fill tag.
<widget area='%AREA.' title='%TITLE.' click='yes' show='buttonon' noshow='buttonoff'
visible='%VISIBLE.' print='no' >
<fill textpaint='buttonup' margin='6' map='scaletofill' image='&BUTTON.OFF' align='center' font='normal'>
<text expand='yes' value='%TEXT.'/>
</fill>
<state on='yes' transient='%RESET.' >
<set name='%SYMBOL.' value='%VALUE.' />
<action command='%COMMAND.' plate='%PLATE.' event='%THROW.' />
<fill textpaint='buttondown' margin='6' map='scaletofill' image='&BUTTON.ON' align='center' font='normal' >
<text expand='yes' value='%TEXT.'/>
</fill>
</state>
</widget>
</macrodef>
<macrodef id='commandbutton'>
<widget area=%AREA. click=yes title=%TITLE. show=buttonon noshow=buttonoff visible=%VISIBLE. print=no >
<fill textpaint=buttonup map=scaletofill image=&BUTTON.OFF font=%FONT. >
<text expand=yes value='%TEXT.'/>
</fill>
<state on=yes command='%COMMAND.' plate='%PLATE.' throw=%THROW. transient=%RESET. >
<fill textpaint=buttondown map=scaletofill image=&BUTTON.ON font=%FONT. >
<text expand=yes value='%TEXT.'/>
</fill>
</state>
</widget>
</macrodef>
// An include allows you to define a group of tags which are reused many times in your application.
// The tags are shared and are treated much like a function call in a programming language.
<includedef id=allCdList >
<widget area=allCdListlist click=no >
<fill paint=bgButton />
</widget>
<listwidget list=cdlibrary selection=multiple selected=cdPlaylist highlighted=cdselectedVolumes
symbol=volume on=yes area=allCdListlist.1.1 click=no
fgcolor=fglist bgcolor=bglist selfgcolor=fgselect selbgcolor=bgselect font=list
update=refreshlist change=readcdvolumes read=readcdvolumes highlightAll=allcdlist
highlightNone=clearcdlist
removeItems=removevolume selectItems=selectvolume unselectItems=unselectvolume >
<fill paint=black/>
</listwidget>
<label area=cdartistlabel text='Artist' />
<comboboxwidget area=cdartistlist symbol=cdselArtist highlighted=cdselArtist list=artists
selected=artistsselected sort=yes
change=cdartistchange on=yes
fgcolor=fglist bgcolor=bglist font=input >
<fill paint=black />
</comboboxwidget>
<label area=cdgenrelabel text='Genre' />
<comboboxwidget area=cdgenrelist symbol=cdselGenre highlighted=cdselGenre list=genres
selected=genresselected sort=yes
change=cdgenrechange on=yes
fgcolor=fglist bgcolor=bglist font=input >
<fill paint=black />
</comboboxwidget>
<label area=cdkeywordlabel text='Keywords' />
<comboboxwidget area=cdkeywordlist symbol=cdselKeyword highlighted=cdselKeyword list=musickeywords
selected=musickeywordsselected sort=yes
change=cdkeywordchange on=yes
fgcolor=fglist bgcolor=bglist font=input >
<fill paint=black />
</comboboxwidget>
</includedef>
.
.
.
// A SmartWidgets application is normally composed of a set of pages called plates.
// Plates are scalable and fully composed. This means that the page layout will be
// consistent no matter what size the actul window is. So your application will
// look the way you intended on any display device. A SmartWidgets application is
// much like a browser based WEB application but with many more mechanisms to interact
// with your custom code and for multiple pages to interact, all without any chatter
// required with an Internet connected server.
<plate id='setupinfo' title='SampSonic Options Setup' --------------------- >
<include name='background' />
<set name='fields' value='fields' />
<set name='labels' value='labels' />
<combobox area='4' label='Window Frame' list='boolean' symbol='frame'
title='Display in normal resizable window' />
<input area='5' label='Window Width' symbol='width' />
<input area='6' label='Window Height' symbol='height' />
<combobox area='7' label='CD Rom Drive Letter' list='cdroms' symbol='CDRom' />
<input area='8' label='CD Rom Rip Drive Number' symbol='cdromrip'
title='CD drive number to use for recording' />
<input area='9' label='CD Rom Play Drive Number' symbol='cdromplay'
title='CD drive number to use for playing' />
<combobox area='10' label='Popup Tooltips' list='boolean' symbol='tooltips'
title='Display popup tooltips' />
<combobox area='11' label='Color Style' list='styles' symbol='style'
title='Select a color profile to use. Must exit program to take effect' />
<logo image='tallpine' />
<selectbar label='Setup' />
<commandbutton text='Apply' area='SelectBtns.2.1' visible='yes' throw='readinput' command='applysetupinfo'
plate='-' offcolor='ltGreen' oncolor='Yellow' reset='yes'
title='Make changes and return' />
<button text='Cancel' area='SelectBtns.3.1' visible='yes' plate='-' oncolor='red' reset='yes'
title='Return without making changes' >
<button text='Photo' area='SelectBtns.4.1' visible='yes' plate='photosetup' oncolor='green'
reset='yes' title='Photo related options' />
<button text='Music' area='SelectBtns.5.1' visible='yes' plate='musicsetup' oncolor='green'
reset='yes' title='Music related options' />
<button text='Buttons' area='SelectBtns.6.1' visible='yes' plate='selectbuttons' oncolor='green'
reset='yes' title='Select button style'/>
<button text='Log' area='SelectBtns.7.1' visible='yes' plate='viewLog' oncolor='green'
reset='yes' title='View log file' />
</plate>
<plate id=selectCdVolume title='All Music CDs' >
<include name=background />
<set name=EDITRETURN value=selectCdVolume />
<set name=MUSICRETURN value=selectCdVolume />
<set name=cdselected object="&LIST(CDLIBRARY)." />
<set name=cdselecteditems object="&LIST(CDSELECTEDVOLUMES)." />
<set name=playlistitem object="&LIST(CDSELECTEDVOLUMES)." />
<logo image=music />
<selectbar label='All CDs' />
<commandbutton text='Done' area='SelectBtns.2.1' visible='yes' command=SELECTCDVOLUMES
throw=readcdvolumes plate=musicoptions offcolor=button
oncolor='Green' reset=yes />
<rocker3button text='- Jukebox +' area='SelectBtns.3.1'
title='Click - to remove from jukebox, + to add to jukebox'
visible='yes' left=unselectvolume right=selectvolume center=gotojukebox
oncolor='Green' reset=yes />
<button text='View' area='SelectBtns.4.1' visible='yes' throw=readcdvolumes oncolor='Green'
reset=yes plate=viewcdvolumeinfo />
<commandbutton text='Add' area='SelectBtns.5.1' visible='yes' plate=addMusicToCdPlayLists
throw=readcdvolumes offcolor=button oncolor='Green' reset=yes />
<commandbutton text='Edit' area='SelectBtns.6.1' visible='yes' throw=readcdvolumes
plate=editcdvolumeinfo offcolor=button oncolor='Yellow' reset='yes' />
<commandbutton text='Remove' area='SelectBtns.7.1'
title='Remove recorded CDs. Places them in the music trash'
visible='yes' throw='removevolume' command='REMOVECDVOLUMES'
offcolor='ltred' oncolor='Green' 'reset=yes' />
<rocker2button text='All - None' area='SelectBtns.8.1' click=click2
title='Click All to highlight all entries, click None to highlight no entries'
visible='yes' left='allcdlist' right='clearcdlist'
oncolor='Green' reset='yes' />
<include name=allCdList />
<include name=cdcontrols />
<button text='Next CD' area='OptionBtns.1.7' visible='yes' throw='nextCD' oncolor='Green' reset=yes/>
<include name=trackstatus />
</plate>
<plate id='selectCdVolume' title='All Music CDs' >
<include name='background' />
<set name='EDITRETURN' value='selectCdVolume' />
<set name='MUSICRETURN' value='selectCdVolume' />
<set name='cdselected' object="&LIST(CDLIBRARY)." />
<set name='cdselecteditems' object="&LIST(CDSELECTEDVOLUMES)." />
<set name='playlistitem' object="&LIST(CDSELECTEDVOLUMES)." />
<logo image='music' />
<selectbar label='All CDs' />
<commandbutton text='Done' area='SelectBtns.2.1' visible='yes' command='SELECTCDVOLUMES'
throw='readcdvolumes' plate='musicoptions' offcolor='button'
oncolor='Green' reset='yes' />
<rocker3button text='- Jukebox +' area='SelectBtns.3.1'
title='Click - to remove from jukebox, + to add to jukebox'
visible='yes' left='unselectvolume' right='selectvolume'
center='gotojukebox' oncolor='Green' reset='yes' />
<button text='View' area='SelectBtns.4.1' visible='yes' throw='readcdvolumes'
oncolor='Green' reset='yes' plate='viewcdvolumeinfo' />
<commandbutton text='Add' area='SelectBtns.5.1' visible='yes' plate='addMusicToCdPlayLists'
throw='readcdvolumes' offcolor='button' oncolor='Green' reset='yes' />
<commandbutton text='Edit' area='SelectBtns.6.1' visible='yes' throw='readcdvolumes'
plate='editcdvolumeinfo' offcolor='button' oncolor='Yellow' reset='yes'/>
<commandbutton text='Remove' area='SelectBtns.7.1'
title='Remove recorded CDs. Places them in the music trash'
visible='yes' throw='removevolume' command='REMOVECDVOLUMES'
offcolor='ltred' oncolor='Green' reset='yes' />
<rocker2button text='All - None' area='SelectBtns.8.1' click=click2
title='Click All to highlight all entries, click None to highlight no entries'
visible='yes' left='allcdlist' right='clearcdlist' oncolor='Green'
reset='yes' />
<include name='allCdList' />
<include name='cdcontrols' />
<button text='Next CD' area='OptionBtns.1.7' visible='yes' throw='nextCD' oncolor='Green' reset='yes'/>
<include name='trackstatus' />
</plate>
</application>