I try to move a JLabel from Position A to Position B sequential in same X and Y Steps.. The Method works correctly, but doesnt't update my gui.. I Show you my code in the following:
When I don't call the .join()
Method, the code works, but don't wait with execution on my another Thread... I need that this function don't call when it actually runs.. Can anybody help me?
Thread MoveThread = new Thread( new Runnable()
{
@Override
public void run()
{
for (int i = 0; i<Const.SteinVerschiebenSchritte; i++)
{
try
{
p_lblToMove.setLocation(p_lblToMove.getLocation().x + x_schritt, p_lblToMove.getLocation().y + y_schritt);
System.out.println("SetLoc");
Thread.sleep(10);
}
catch (InterruptedException ex)
{
StatusLog("InterruptedException");
}
}
System.out.println("invokeLater");
p_lblToMove.setLocation(p_lblToMove.getLocation().x + x_offset, p_lblToMove.getLocation().y + y_offset);
}
});
MoveThread.start();
try {
System.out.println("BeforeJoin");
MoveThread.join();
System.out.println("AfterJoin");
System.out.println("------------------");
} catch (InterruptedException ex) {
Logger.getLogger(Spielfeld.class.getName()).log(Level.SEVERE, null, ex);
}