Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Simple Java App

  1. #1
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Simple Java App

    I'm doing something wrong here, and I'm not to sure what I'm doing wrong. I'm obviusly new to Java, and just trying to get a hang of it.

    Code:
    import java.awt.*; import java.applet.*;
    
    public class NewApp extends Applet {
    	
    	public void init() 
    	{
    	
    	Color mySytle=new Color(666);
    	setBackground(myStyle);
    	resize(150, 50);	
    		
    	}
    	
    	public void paint(Graphics g) {
    		
    		g.drawString("This is my string. Hello everyone!", 50, 20);
    	}
    	
    }
    Last edited by Jon W; 12-01-2008 at 05:48 PM.

  • #2
    New Coder
    Join Date
    Jun 2005
    Posts
    32
    Thanks
    0
    Thanked 2 Times in 2 Posts
    When I run this, it seems to work fine although I did have to fix a typo in the code you posted:

    Color mySytle=new Color(666);

    I changed mySytle to myStyle.

    I saw the string painted in black on a blue background.


  •  

    Posting Permissions

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