Java Compiler wrote:No enclosing instance of type MiniMusicPlayer is accessible. Must qualify the allocation with an enclosing instance of type MiniMusicPlayer (e.g. x.new A() where x is an instance of MiniMusicPlayer).
This has to do with the class MyDrawPanel being a nonstatic inner class. As the error says, you need an instance of MiniMusicPlayer to instantiate ml. So for instance, this works:
So why does it work in the method setUpGui()? Because at that point in the code, you do have an instance of MiniMusicPlayer: it's called this. These two lines: ... are semantically equivalent.
All things are lawful, but not all things are profitable.
posted 2 months ago
Thank you so much.
Lasagna is spaghetti flvored cake. Just like this tiny ad: