Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Applet problem...
Jeremy Parsons
Ranch Hand
Posts: 74
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Just started learning about
Applets
, and I am trying to compile the code below which is straight out of the book, but it will not compile, am I over looking something here?
import java.applet.*; import java.awt.*; public class App extends Applet { Label greeting = new Label("Hello how are you?"); Font myfont = new Font("Helvetica", Font.BOLD,36); public void init() greeting.setFont(myfont); { add(greeting); } }
Keith Lynn
Ranch Hand
Posts: 2412
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Notice where you have the opening brace of the method.
Jeremy Parsons
Ranch Hand
Posts: 74
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I'm getting the following error..
C:\WINDOWS\Desktop\App.java:10: ';' expected greeting.setFont(myfont); ^ 1 error Tool completed with exit code 1
I looked at the method but couldn't find anything wrong..
Keith Lynn
Ranch Hand
Posts: 2412
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public void init() greeting.setFont(myfont); { add(greeting); }
Notice here that you have a line of code before the opening brace.
Jeremy Parsons
Ranch Hand
Posts: 74
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
ah, ok.. when you said method I was looking at the public void init() part not the method body and brackets.. Got it working now, I appreciate that..
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
repaint() method? Something's fishy...
Help with screen output in applet
Hmmm... ??
Problem in Font
Applet Problem...
More...