int dot = path.lastIndexOf(".");
String ext = path.substring(dot + 1);
if (ext.equals("jpg") || ext.equals("png")) {
PImage image = applet.loadImage(path);
PImage imageCpy = applet.createImage(thumbSize, thumbSize, 2);
if (image.width > image.height)
imageCpy.copy(image, 0, 0, image.height, image.height, 0,
0, thumbSize, thumbSize);
else
imageCpy.copy(image, 0, 0, image.width, image.width, 0, 0,
thumbSize, thumbSize);
//image.resize(40, 40);
button = new GUIButton(0, 0, imageCpy, null, GLOBAL.applet, gui);