import SpringGUI.*; /* This demonstrates how to create GUI elements with SpringGUI. This example will not do much with the elements, when the user interacts with them - it will only display the last event that happened and its parameters as a text string on the bottom of the screen. */ SpringGUI gui; // This is our instance of SpringGUI on which we will call all GUI related methods. void setup() { size(600,300); // make a nice large canvas... // load a font to use for text-output... PFont font = loadFont("TrebuchetMS-11.vlw"); textFont(font); background(0,0,0); // clear the screen; gui = new SpringGUI(this); // <--- this line MUST be placed before gui can be used. gui.addButton("myButton", "I am a Button", 10, 10, 180, 20); // create a button named "myButton" at coordinates 10, 10 gui.addTextField("myTextField", "I am a TextField", 10, 40, 180, 20); // create a single line TextField named "myTextField" gui.addTextArea("myTextArea", "I am a TextArea", 10, 70, 180, 50); // create a multi line TextArea named "myTextArea" gui.addCheckbox("myCheckbox", "I am a Checkbox", 10, 130, 180, 20); // create a Checkbox named "myCheckbox" // create two Radiobuttons belonging to the group "group1" gui.addRadiobutton("myRadiobutton1", "I am a Radiobutton", "group1", 10, 160, 180, 20); gui.addRadiobutton("myRadiobutton2", "I am also a Radiobutton", "group1", 10, 190, 180, 20); gui.setState("myRadiobutton1", true); // select Radiobutton 1 // the Radiobuttons and Checkbox have white backgrounds and black text... we will switch these colors: gui.setBackground("myCheckbox", 0,0,0); gui.setBackground("myRadiobutton1", 0,0,0); gui.setBackground("myRadiobutton2", 0,0,0); gui.setForeground("myCheckbox", 255,255,255); gui.setForeground("myRadiobutton1", 255,255,255); gui.setForeground("myRadiobutton2", 255,255,255); gui.addChoice("myChoice", 10, 220, 180, 20); // create a Choice named "myChoice" gui.addItem("myChoice", "Item 1"); // add Items to the Choice gui.addItem("myChoice", "Item 2"); gui.addItem("myChoice", "Item 3"); gui.addItem("myChoice", "Item 4"); gui.addItem("myChoice", "Item 5"); gui.selectItem("myChoice", "Item 1"); // select the item named "Item 1" in the Choice gui.addList("myList", 200, 10, 200, 250); // create a List named "myList" gui.setListMultipleMode("myList", true); // this List can have several items selected at the same time for (int i=1; i<=30; i++) { // let's add 30 elements named "Item 1" to "Item 30" gui.addItem("myList", "Item "+i ); } gui.selectItem("myList", "Item 1"); // select the item named "Item 1" in the List } void draw() { } // this method is called whenever an event takes place: void handleEvent(String[] parameters) { String eventDesc = "type of object: "+parameters[0]+"; object name: "+parameters[1]+"; event: "+parameters[2]; // create a description of the event for (int i=3; i