public class SecondFrame01 extends javax.swing.JApplet {
int xPos = 0;
int yPos = 0;
int delta = 1;
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void jButton1MousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
yPos = yPos - delta;
jLabel1.setLocation(xPos, yPos);
}
private void jButton2MousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
yPos = yPos + delta;
jLabel1.setLocation(xPos, yPos);
}
private void jButton3MousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
xPos = xPos - delta;
jLabel1.setLocation(xPos, yPos);
}
private void jButton4MousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
xPos = xPos + delta;
jLabel1.setLocation(xPos, yPos);
}