Hello every one i need help in this simple program
I encounter two problems when running this program
first, the close button doesn't work although i write a line to handle this
second, when i maximize the window the fan doesn't fit the window
I'd be grateful if you help me and i will be very happy i you give me your notes to improve my simple project
I haven't large experience in java but i try to learn
this is the code
I Hear I Forget, I See I Remember, I Do I Understand.
Your code doesn't compile; in line 85 there is a variable fa that is not declared anywhere.
The reason why your code doesn't work properly is this: The Swing toolkit for making GUIs uses threads in a specific way. The most important thread to be aware of is the event dispatch thread, on which Swing will run all painting code and all callbacks to handle events such as button clicks.
Your paint() method never returns - it contains a never ending loop in lines 72 - 98. That means that you block the event dispatching thread forever, so that your program cannot react to events anymore, such as resizing or closing the window.
To make your program run smoothly, you must always make sure that things that run on the event dispatch thread return as quickly as possible. You must put the code from lines 72 - 98 somewhere else, and not inside the paint() method or another method that runs on the event dispatch thread.