Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2012
    Rep Power

    Default frame.add( hello );

    Hello I'm really new to Java I just downloaded a book by O'Reilly Media called Learning Java. I'm on the first chapter and I'm already stuck

    Here's the code so far
    Java Code:
    package hellojava;
    import java.awt.Graphics;
    import javax.swing.*;
    public class Hellojava {
    public static void main(String[] args) {
            JFrame frame = new JFrame( "Hello, Java!");
            frame.add( hello );
            frame.setSize (300,300);
    class HelloComponent extends JComponent {
          HelloComponent hello = new HelloComponent();
        public void paintComponent(Graphics g){
            g.drawString("Hello, Java!", 125, 95);
    I'm using NetBeans and it's saying "Cannot find symbol" on the line that has
    Java Code:
    frame.add( hello );
    on it

    When I try and run it I get an error message saying:

    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>
    at hellojava.Hellojava.main(
    Java Result: 1
    BUILD SUCCESSFUL (total time: 2 seconds)

    Can someone help I'm thinking there's a really simple solution to this but when I try and search for an answer it doesn't help because I don't understand what anybody's talking about.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

Similar Threads

  1. Replies: 7
    Last Post: 04-01-2012, 04:11 AM
  2. Replies: 4
    Last Post: 01-18-2011, 08:22 AM
  3. how to open one frame to another frame
    By tukadiya in forum AWT / Swing
    Replies: 1
    Last Post: 12-20-2010, 08:27 PM
  4. Java slave Frame access to its owner main frame problem
    By cagdaseckin in forum New To Java
    Replies: 0
    Last Post: 12-10-2010, 10:40 AM
  5. Replies: 7
    Last Post: 11-02-2009, 06:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts