Haina Soft wrote:Hi Jerry Kis,
What's type of the frame object? I guess it is type of JFrame, right? So the above does not work because a JFrame cannot be cast to a JLabel. It will throw an exception at runtime.
What's the purpose of that function, if it is simply to return a JLabel, so the code looks really ugly.
Thank you for your reply. The frame is a JFrame, it's the main window in the StdDraw library which is made to make simple stand-alone graphics. The JFrame only has one component on it, a JLabel that has all the drawing. Earlier I put the
test below to confirm that the component being returned is in fact a JLabel.
It always prints that it's a JLabel. I want to somehow put the JLabel into a JApplet, and the getJLabel method is what I came up with. I am very new to Swing and JApplets.