I made this whilst in high school, when I learnt java by myself. (Therefore may have unknowingly done stuff pro's wouldn't do.) Last I checked (5 minutes ago), all the examples still worked. It should be rather fast. IMO I made it a little too verbose though. There is no documentation. There are examples for [Checkboxes, Buttons, Textfield, psuedo-windows]. Also included is the source code. There are comments in the code, maybe that'll help you. But I looked at them just now and they seem rather messy.
It has an 'optimized mode' which makes the library use little to no additional processing power to the p5 app when idle. I couldn't get rid of some artifacts so I didn't set it on as default.
I hereby toss my library to you guys out there, under LGPL http://www.gnu.org/copyleft/lgpl.html (I remember looking at some source code for textfields from interfascia which is licensed under LGPL, so in case I copied anything....) and Disclaimer: I'll not be responsible if you guys stuff up your computer (Or have damage caused.) when using my library due to it being released under LGPL.
Download: http://www.savefile.com/files/1483067
Example for textfield and button:
Code:
import groupedWidgets.*;
PFont font;
groupedWidgets guiwid;
widgetEventsClass widgetEventsObject;
void setup()
{
size(320,135);
frameRate(30);
font=loadFont("ArialMT-14.vlw");
textFont(font,32);
guiwid=new groupedWidgets(this,font);
guiwid.setOptimize(false);
guiwid.addGroup("Group1");
guiwid.getGroup("Group1").setGroupX(10);
guiwid.getGroup("Group1").setGroupY(10);
guiwid.getGroup("Group1").setGroupWidth(300);
guiwid.getGroup("Group1").setGroupHeight(75);
guiwid.getGroup("Group1").setGroupBackground(color(80,80,5,100));
guiwid.getGroup("Group1").setGroupBorder(color(20,20,5,100));
guiwid.getGroup("Group1").wGmakeImages();
guiwid.getGroup("Group1").addTextfield("Textfield1", 10,10); //Coordinates relative to the group, not the window
guiwid.getGroup("Group1").getWidget("Textfield1").setWidth(280);
guiwid.getGroup("Group1").getWidget("Textfield1").setBackground(color(255,255,255,255));
guiwid.getGroup("Group1").getWidget("Textfield1").setPressedColor(color(240,240,240,255));
guiwid.getGroup("Group1").getWidget("Textfield1").setLabel("Enter Text Here");
guiwid.getGroup("Group1").getWidget("Textfield1").setTextColor(color(0,0,0,255));
guiwid.getGroup("Group1").getWidget("Textfield1").widgetMakeImages();//call this after editting button every time.
guiwid.getGroup("Group1").getWidget("Textfield1").setWidgetRespondIfNotInFront(false);
guiwid.getGroup("Group1").addButton("Button2", 10,40);
guiwid.getGroup("Group1").getWidget("Button2").setWidth(280);
guiwid.getGroup("Group1").getWidget("Button2").setBackground(color(200,200,0,255));
guiwid.getGroup("Group1").getWidget("Button2").setPressedColor(color(180,180,0,255));
guiwid.getGroup("Group1").getWidget("Button2").setLabel("Prints Text When Released");
guiwid.getGroup("Group1").getWidget("Button2").setTextColor(color(0,0,0,255));
guiwid.getGroup("Group1").getWidget("Button2").widgetMakeImages();//call this after editting button every time.
//Create and Connect Handler to detect mouseEvents such as mouseReleased performed on buttons.
widgetEventsObject=new widgetEventsClass();
guiwid.setWidgetEventsHandler(widgetEventsObject);
}
void draw()
{
background(0);
}
class widgetEventsClass implements widgetEventsHandler
{
public void widgetReleased (String widgetName)
{
if (widgetName.equals ("Button2"))
{
print (guiwid.getGroup("Group1").getWidget("Textfield1").getLabel());
print (" ");
}
}
public void widgetPressed (String widgetName)
{
}
public void widgetDragged (String widgetName)
{
}
}