-
May 1st, 2022, 09:58 AM
#1
[RESOLVED] Java Generics : How to pass object having generic type to another class?
I prepared a code using Java Generics to gain flexibility. I had one class named ImagePanel<T> extends Node<T> class that is also extends Panel (java.awt.Panel) class. The other class is PanelManager manages ImagePanel<T> class objects. I define both classes in the same file (GUI.java file - GUI class).
However, compiler gives this error :
"Note: spritesGUI/SpritesWindow.java uses unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details."
The structure is :
Code:
class GUI {
class ImagePanel<T> extends Node<T> { ... }
class PanelManager { ... public void ImagePanel getSleectedImagePanel(); }
}
As you see, I have "getSleectedImagePanel()" method which returns ImagePanel. I do not know how to transfer generic type T to PanelManager? Any help is appreciated.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|