Hierarchical Layout is a tip of GUI scripting with Pnuts, although it can be used even in Java.
|
layout() does the same as pnuts.awt.Layout.layout().
e.g.
![]() | import("java.awt.*") import("pnuts.awt.*") f = frame("test") f.show() layout(f, [PnutsLayout, "expand=xy", b1 = Button("OK") ] ) |
![]() |
import("java.awt.*") fr = frame("test") layout(fr, [BorderLayout, [], ["North", [FlowLayout, [], Button("A"), Button("B"), Button("C")]], ["East", Button("2")], ["West", Button("3")], ["South", Button("4")], ["Center", [BorderLayout, [], ["North", Button("11")], ["East", Button("22")], ["West", Button("33")], ["South", Button("44")], ["Center", [GridLayout, [0, 2], Button("55"), [CardLayout, [], ["", b1=Button("one")], ["", b2=Button("two")], ["", b3=Button("three")]]]]]]]) buttons=[b1, b2, b3] foreach i (buttons){ bind(i, "actionPerformed", function (e) { c = i.getParent() c.getLayout().next(c) }) } fr.show() |