|
Tutorial Example
IntroductionJGoodies Forms offers ButtonBarFactory which produces some predefined layouts for
buttons. Well, one can do similar things with XML using the 1. Write a Template LayoutSay one has a template layout for Add and Remove buttons.
We can define them in
<panel> <buttonbarbuilder> <form-add gridded="true" related="true"> <button id="addButton" text="Add" mnemonic="VK_A"/> <button id="removeButton" text="Remove" mnemonic="VK_R"/> </form-add> <form-glue/> </buttonbarbuilder> </panel> Note that I assign an id for each button. The purpose is to be able to refer to these buttons later on. 2. Include the TemplateWe can then include this template inside the XML file where we need the panel. <include ctor="examples/cookformlayout/xml/template_addremove_left.xml"/> 3. Hook ListenersSince we have assigned buttons with certain ids, we can refer them after we include the template panel. Then we can hook up listeners like what we do normally in CookSwing. <noadd> <button idref="addButton" actionlistener="addAction"/> </noadd> |