IDE: Eclipse photon 4.8 MacBook: Catalina 10.15.7 Language: java8
addWindowListener(new WindowAdapter() {
// @SuppressWarnings("unused")
public void windowClosing (WindowEvent e) {
dispose();
System.exit(0);
}
});
@SuppressWarnings ("unused ")
is a comment proposed by Eclipse. When I insert this, the error disappears, but I'm telling the JVM that I'm not using it, so I don't have to recognize any unused variables as an error. The person who wrote it also knows `so a comment to prevent the error from being displayed.
In other words, it hasn't been solved!
Of course, you can't close the window. But I'm going to write it according to the teaching materials.
//An error occurs in this part
public void windowClosing (WindowEvent e) {
Since the suggestion to import com.sun.glass.events.WindowEvent
came out at the top of the editor of Eclipse, I added an import statement.
import com.sun.glass.events.WindowEvent;
** This was the cause. ** **
The next error displayed is
The method windowClosing (WindowEvent) from type new WindowAdapter () {} is not used locally
I'm sorry I fixed it as Eclipse said. What is it?
The simple error above is that you can't use the method, but ... why did you do what Eclipse said, but it didn't seem to be resolved.
From there it is suggested to insert the following comment
@SuppressWarnings("unused")
No, I'm not using this. .. ..
Looking at the teaching materials, it seems that the relevant parts are completely the same even when compared with the sample. Even if you copy and paste the relevant part of the sample, the same error will occur, so it is unlikely that there is a spelling mistake or invisible code mixed in. .. .. ..
So I went to the swamp more and more. .. .. ..
I also went back to the code with the first error, checked the suggestions displayed in Eclipse, and scrolled down to find another suggestion.
There was a suggestion like importing
java.awt.Event`.
Isn't that the case? I thought it was bingo.
If you are inexperienced, it is a mistake to think that you should adopt the proposal part that appears at the top of ʻEclipse and correct it. Absolutely no.
import java.awt.Event;
If so, it was solved in an instant.
It was here. It's in a different package. It's complicated.
After all, this took a lot of time. .. .. ..
This is what I think,
It seems stupid that it took about 2 hours even though it was a terrible mistake that the import statement was wrong at most, but I believe that such an experience will be acquired.
Basically, I can solve the error myself, but when a similar error appears, it is much faster than what I was told.
Then, somehow the error resolution procedure became my own form, so I felt that the procedure itself could be used for new errors.
Recommended Posts