import SpringGUI.*; /* This demonstrates how to use the events "mouseEntered" and "mouseExited" to create rollover effects on buttons and textfields. */ SpringGUI gui; // This is our instance of SpringGUI on which we will call all GUI related methods. void setup() { size(200,150); // canvas size... background(0,0,0); // clear the screen; gui = new SpringGUI(this); // <--- this line MUST be placed before gui can be used. gui.addButton("myButton1", "I am a Button", 10, 10, 180, 20); // create a button gui.addButton("myButton2", "I am also a Button", 10, 40, 180, 20); // create another button gui.addTextField("myTextField1", "I am a TextField", 10, 70, 180, 20); // create a single line TextField gui.addTextField("myTextField2", "I am also a TextField", 10, 100, 180, 20); // create another single line TextField gui.setAllBackgrounds(64,64,64); gui.setAllForegrounds(255,255,255); } void draw() { } // this method is called whenever an event takes place: void handleEvent(String[] parameters) { // Whenever the mouse enters a Button (no matter which one), set the Button's background to red. // When it leaves the Button, set its background back. if ( parameters[0].equals("Button") && parameters[2].equals("mouseEntered") ) { gui.setBackground(parameters[1], 164,0,0); } else if ( parameters[0].equals("Button") && parameters[2].equals("mouseExited") ) { gui.setBackground(parameters[1], 64,64,64); } // Whenever the mouse enters a TextField (no matter which one), set the TextField's background to blue. // When it leaves the TextField, set its background back. if ( parameters[0].equals("TextField") && parameters[2].equals("mouseEntered") ) { gui.setBackground(parameters[1], 0,128,164); } else if ( parameters[0].equals("TextField") && parameters[2].equals("mouseExited") ) { gui.setBackground(parameters[1], 64,64,64); } }