This may be a stupid mistake of some sort on my part, but I'm walking through a Java GUI tutorial. When I copy and paste code from the tutorial into Eclipse, it finds an error in the pasted code. Trying to run it anyways yields console errors and an empty GUI window.
For example:
Checkbox chk15to20 = new Checkbox(“15 to 19 years old”, true, age);
Eclipse yields an error on the argument string, saying "Syntax Errors, ArgumentList expected instead" and "years cannot be resolved to a type."
I can fix the problem by manually re-typing, character by character, the code, at which point it compiles correctly.
Here's the error log when it's run (class is called Buttons):
java.lang.Error: Unresolved compilation problems: Syntax error on tokens, ArgumentList expected instead years cannot be resolved to a type Duplicate field Buttons.old Syntax error on tokens, ArgumentList expected instead Duplicate field Buttons.old
at practice1.Buttons.<init>(Buttons.java:13)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Your double-quotes are wrong. You need to use normal double-quotes, i.e. press SHIFT and ' on a US keyboard.
Like this:
Checkbox chk15to20 = new Checkbox("15 to 19 years old", true, age);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With