This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!

Jerry Kis

Greenhorn
+ Follow
since Oct 12, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jerry Kis

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.
7 years ago
Hi all,

I'm a new visitor to this forum and have already learned some things. I have some (but not lots) of OOP programming experience and little with Swing and applets, although I'm learning.

Right now I'm trying to take some simple animations made with the help of the StdDraw library (http://introcs.cs.princeton.edu/java/stdlib/StdDraw.java.html) and make them into applets so they can be shared on the web. The author gives permission to modify StdDraw, and suggested I get the JLabel from the StdDraw frame and put it into a JApplet. I've tried several ways with no success yet and am stuck. I will appreciate any help.

I added this to StdDraw.java:

There is only one component on the JFrame, a JLabel.

Here is my applet:

7 years ago