• 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

Compiler output to troubleshoot

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, here's greenhorn nbr1!
I would like to compile the following code, but get 5 errors.
Here's the code, then follows the compiler's output. Can you help me to troubleshoot?
Thanks, Patrick

Code:
import java.awt.*;
import javax.swing.*;

class MeinZeichenPanel extends JPanel {
public void paintComponent(Graphics g);
g.setColor(Color.orange);
g.fillRect(20,50,100,100);
} // end of PaintComponent
} // end of class MeinZeichenPanel

Compiler Output:

MeinZeichenPanel.java:6: <identifier> expected
g.setColor(Color.orange);
^
MeinZeichenPanel.java:6: <identifier> expected
g.setColor(Color.orange);
^
MeinZeichenPanel.java:7: <identifier> expected
g.fillRect(20,50,100,100);
^
MeinZeichenPanel.java:7: illegal start of type
g.fillRect(20,50,100,100);
^
MeinZeichenPanel.java:9: class, interface, or enum expected
} // end of class MeinZeichenPanel→
^
5 errors
 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simply add a brace instead of the semi colon like that:
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic