public static void shake(Component cp) {
int x = cp.getLocation().x;
int y = cp.getLocation().y;
for (int i = 0; i < 6; i++) {
try {
Thread.sleep(30);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (i % 2 == 0) {
x += 5;
y += 5;
} else {
x -= 5;
y -= 5;
}
cp.setLocation(x, y);
}
}