View Full Version : Java Help

Apr 29, 2013, 01:18 AM
Any of you good at java? I have a quick question
My code wont compile. The error is in the main method. Every time i try to call hr and m to get the randomly generated time to compare with the user time, it gives me the red error line.
Am i not linking the class to the Main method right?

Apr 29, 2013, 10:10 AM
Before you get yelled at, you should go here and fix your post http://forums.macrumors.com/showthread.php?t=1356447

What error is it giving you?

Apr 29, 2013, 10:16 AM
I think you accidentally forgot to create the variable "s". You could change
private static final SwingCanvas SwingCanvas = null;
private static SwingCanvas s = null;

and then change your Clock constructor to set that variable by changing
setContentPane(new SwingCanvas());
s = new SwingCanvas();

It has been years since I've done Java GUI development so I have no idea if you are following best practices but these changes will at least fix your error.

Hope this helps,


Apr 29, 2013, 09:23 PM
Thank you so much! Other than my if statements it works!