Skip to content
Advertisement

why all thing is stop when i’ll use while loop in MouseEntered() Function ?? In Java

My gui programme that contains (JPanel ,JFrame ,JLabel) JLabel : I Coded it To move from (0x, 0y) To (200x ,0y) Pixel by Pixel . it will start when i put the mouse on the panel called “p” ,but when i try to run this programme it’s start correctly ,but when i put my mouse on the panel all thing stop to a few seconds The Label Moved to Point (200x, 0y) Any One Had Any Answer To Solve This Problem.

The Class Had The Problem :-

JavaScript

The Main Class That Run The JFrameClass class :-

JavaScript

Advertisement

Answer

You’re running your code on the Event-Dispatch-Thread. That’s a no-no. Put the code in your mouseEntered into a SwingWorker.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement