Results 1 to 3 of 3
  1. #1
    mindsword is offline Member
    Join Date
    Jul 2014
    Location
    Norway
    Posts
    16
    Rep Power
    0

    Smile Making GUI to basic "Hello World" like program "Frank"

    I started Java today, and i made a simple variation of Hello World called Frank. Im trying to make it more personlike with a yellow smiley for "face", and make it say "Hi, I am Frank. I am a robot." in the box.

    Java Code:
    import javax.swing.JFrame;
    public class Frank {
     static JFrame aWindow = new JFrame("Frank!");
     public static void main(String[] args) {
    int windowWidth = 444;
        int windowHeight = 444;
       aWindow.add(new JLabel("I am Frank. I am a Robot."));
       aWindow.setBounds(50, 100,windowWidth, windowHeight);
        aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        aWindow.setVisible(true);
        
    }}
    The problem is the: JLabel("I am Frank. I am a Robot.")); - part.......

    In which i get:
    Java Code:
    error: The method JLabel(String) is undefined for the type Frank
    	aWindow.add(JLabel("I am Frank. I am a Robot."));
    	                    ^^^^^^
    1 problem (1 error)
    Where did i go wrong? Babysteps; please. Thanks..

    Also: Would you reccomend Java for this particular purpose? Im gonna try just to see how intelligent/humanlike i can make Frank, while keeping his yellow smiley face..

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,614
    Rep Power
    5

    Default Re: Making GUI to basic "Hello World" like program "Frank"

    You need to import javax.swing.JLabel.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    mindsword is offline Member
    Join Date
    Jul 2014
    Location
    Norway
    Posts
    16
    Rep Power
    0

    Default Re: Making GUI to basic "Hello World" like program "Frank"

    Thanks dude! Figured it out.

    Any way to centre the text? Where do i set the public CenterText() { and do i need anything else?
    Last edited by mindsword; 07-27-2014 at 11:32 PM.

Similar Threads

  1. Replies: 0
    Last Post: 12-07-2012, 08:29 AM
  2. Replies: 3
    Last Post: 10-30-2012, 03:06 PM
  3. Program skips "If" code and goes straight to "Else"
    By Logik22 in forum New To Java
    Replies: 12
    Last Post: 01-21-2012, 05:40 PM
  4. Newbie question about basic code - "Hello World"
    By Kimomaru in forum New To Java
    Replies: 3
    Last Post: 10-13-2011, 06:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

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