menubar {
"File" {
"Open" do="open" // calls "open()" in the controller
"---"
"Exit" do="exit"
}
}
Thats it. The strings in the menubar are automatically interpreted as menus and menu items. The "do" attributes call an action method in the controller associated with the form containing this menubar. SDL attributes are converted to bean properties. This allows you to easily configure components like so:button "Hello" opaque=false icon="waving_hand.png" foreground="red"The "button" tag below is mapped to javax.swing.JButton in a bindings property file. There are default bindings for common components. Application developers can add their own bindings or override default bindings like so:
button=com.ooi.swing.RoundButtonContainer components take a "layout" attribute that maps to one of about a dozen layout managers ranging from simple vertical and horizontal stacking layouts to complex table layouts. Here is a browser bar (the area with the URL and buttons at the top of your browser) using a vertical layout:
hpane border="2,2,2,2" {
"URL: "
text constraint="fill"
spacer 5
button "<"
button ">"
}
Result:JComponent browser = UI.build("comps/browser.sdl");
Examples of more complex layouts including table and spring can be seen here:
button "@yes"This button will display "Oui" in the french locale. SDL/Swing looks up the strings in UTF8 property files located in the locales directory. This part of the localization system has been ported to C# as well.
form ID="Browser" {
hpane loc="north" border="2,2,2,2" \
preferredHeight=24 {
"URL" border="0,5,0,3" font="strong"
button "Clear" do="clearURL" focusPainted=false
text "http://www.cnn.com" constraint="fill" do="browseTo" minimumSize="5,5"
button "Go" background="dark_green" do="browseTo"
spacer 7
button icon="recycle" do="refresh" style="toolbar"
spacer 5
button icon="navigate_left" do="back" style="toolbar"
button icon="navigate_right" do="forward" style="toolbar"
}
browser URL="http://cnn.com" ID="browser"
}

Tags: declarative ui, sdl, sdl/swing, sdl/ui, swing, ui programming
Comment
© 2010 Created by Daniel Leuck
You need to be a member of TechHui to add comments!
Join TechHui