[SOLVED] JScrollPane - ClassCast Exception
In my code I have class CustomPanel which extends JPanel. myPanel is an instance of CustomPanel (for your info, myPanel is a white space used as sketchpad)
I am in the process of making myPanel scrollable. I am getting the following error during runtime when i begin by drawing the first object on myPanel:
"Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JViewport cannot be cast to javax.swing.JPanel"
The following is the code used for making myPanel scrollable:
JScrollPane scrollPane=new JScrollPane();
scrollPane.getViewport().add( myPanel );
Container container = getContentPane();
Please advice. Thank you.