Java Move JPanel Inside The JForm
How To Move Object Around The Form In Java
In This Java Tutorial We Will See How To Move JPanel UP, RIGHT, DOWN, LEFT In The Form By Pressing Arrow Keys Using Java Programming Language And NetBeans Editor.
Project Source Code:
private void formKeyPressed(java.awt.event.KeyEvent evt) {
int key = evt.getKeyCode();
switch(key)
{
case KeyEvent.VK_UP:
jPanel1.setLocation(jPanel1.getLocation().x, jPanel1.getLocation().y - 5);
break;
case KeyEvent.VK_DOWN:
jPanel1.setLocation(jPanel1.getLocation().x, jPanel1.getLocation().y + 5);
break;
case KeyEvent.VK_RIGHT:
jPanel1.setLocation(jPanel1.getLocation().x + 5, jPanel1.getLocation().y);
break;
case KeyEvent.VK_LEFT:
jPanel1.setLocation(jPanel1.getLocation().x - 5, jPanel1.getLocation().y);
break;
}
}
///////////////OUTPUT:
Posting Komentar untuk "Java Move JPanel Inside The JForm"