Recent Changes for "Example 1: A Simple Button." - Graph Exploration System (GUESS)http://guess.wikispot.org/Example_1:_A_Simple_Button.Recent Changes of the page "Example 1: A Simple Button." on Graph Exploration System (GUESS).en-us Example 1: A Simple Button.http://guess.wikispot.org/Example_1:_A_Simple_Button.2007-08-11 00:32:48EytanAdarUpload of image <a href="http://guess.wikispot.org/Example_1:_A_Simple_Button.?action=Files&do=view&target=example1.jpg">example1.jpg</a>.Example 1: A Simple Button.http://guess.wikispot.org/Example_1:_A_Simple_Button.2007-08-11 00:32:34EytanAdar <div id="content" class="wikipage content"> Differences for Example 1: A Simple Button.<p><strong></strong></p><table> <tr> <td> <span> Deletions are marked with - . </span> </td> <td> <span> Additions are marked with +. </span> </td> </tr> <tr> <td> Line 1: </td> <td> Line 1: </td> </tr> <tr> <td> </td> <td> <span>+ = Example 1: A Simple Button =<br> + <br> + <br> + Lets say we want to modify the interface to have a button that when pressed will center the display. We could create a new type of object called a dockexample1 in the following way:<br> + <br> + <br> + {{{<br> + import java # import what we need<br> + import javax.swing<br> + import com<br> + <br> + <br> + class dockexample1(com.hp.hpl.guess.ui.DockableAdapter):<br> + <br> + <br> + def __init__(self):<br> + # create a new button called center<br> + testButton = JButton("center")<br> + <br> + # every time the button is pressed, center the display<br> + testButton.actionPerformed = lambda event: center()<br> + <br> + # add the button to the toolbar<br> + self.add(testButton)<br> + <br> + # add the toolbar to the main UI window<br> + ui.dock(self)<br> + <br> + def getTitle(self):<br> + # define the title in the window<br> + return("dockexample1")<br> + }}}<br> + <br> + <br> + If we save this script to a file called example.py we can make use of it in GUESS by executing the file:<br> + <br> + {{{execfile(“example.py”)}}}<br> + <br> + <br> + and then creating a new dockexample1 object:<br> + <br> + {{{dockexample1()}}}<br> + <br> + --&gt;<br> + [[Image(example1.jpg)]] &lt;--</span> </td> </tr> </table> </div>