Evening,
I was playing around with a little swing application, and I added a button which was to respond to being pressed. Therefore I needed to implement ActionListener. I had already added this line:
import java.awt.*;
but it informed me that it could not find the “ActionListener” class.
So after a few moments I ended up
with this:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
I was under the assumption that the awt.* part meant that it was importing all sub-packages under the awt umbrella. Apparently this isn’t the case. Can someone please clarify this problem for me?
This imports all classes under in the awt package, not subpackages.
The main reason is that java packages are not nested, even if their names makes you think they are.
java.awtandjava.awt.eventcan be seen as two unrelated packages.