InfoQ HomepageNewsWiki-style GUI Layout with Profligacy and LEL
Wiki-style GUI Layout with Profligacy and LEL
Jul 13, 20071min read
Write for InfoQ
Feed your curiosity.Help 550k+ globalsenior developers
each month stay ahead.Get in touch
GroupLayout, is well suited to be configured by GUI builders like Matisse.The latest attempt at a solution uses JRuby. Zed Shaw, creator ofMongrel, created a JRuby GUI library calledProfligacy (InfoQreported about JRuby GUI libraries Profligacy, Cheri and Swiby). It includesLayout Expression Language (LEL) which aims to tackle the GUI layout problem.
LEL uses a Wiki-style formatting language to define the layout as text. This makes the layout specification a compact string, instead of many lines of code specifying constraints or setting up hierarchies of panels. The language is parsed by a parser written using the Ruby libraryRagel.
A sample:
layout = "This creates a layout decoupled from the creation of the actual components, by setting up named placeholders for the layout elements. Layout and components are then connected with a bit of Ruby code:
[ label_1 | label3 ]
[ (300,300)*text1| (150)people ]
[<label2 | _ ]
[ message | buttons ]
"
ui = Swing::LEL.new(JFrame,layout) do |c,i|
c.label_1 = JLabel.new "The chat:"
c.label2 = JLabel.new "What you're saying:"
c.label3 = JLabel.new "The people:"
c.text1 = JTextArea.new
c.people = JComboBox.new
c.message = JTextArea.new
# we'll replace this later with a subcomponent
c.buttons = JPanel.new
end
The placeholders defined in the layout specification (
label_1,text1, etc) are assigned concrete components by referring to their names, which is done using Ruby's metaprogramming features.While there are other LayoutManagers that use the approach of text layout constraints, for instanceMigLayout, Profligacy and LEL show an interesting approach to help with GUI programming by using Ruby's features. LEL is not specific to a particular LayoutManager, although the current version uses
GroupLayout to set up the GUI.This content is in theJava topic
Related Topics:
Related Editorial
Related Sponsor
%2ffilters%3ano_upscale()%2fsponsorship%2ftopic%2f7373d294-342f-423d-ad2d-c4145c0f9caf%2fOrkesLogoMicrosite-1758623718367.png&f=jpg&w=240)
Master Workflow & Microservices Orchestration at Scale. See how Orkes, built on Netflix Conductor, helps teams simplify event-driven systems while ensuring reliability and enterprise readiness.Learn More.
The InfoQ Newsletter
A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers.View an example