Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: MyFirstApplet problems - FOR THE LOVE OF EVERYTHING HOLY, PLEASE HELP, LOL

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default MyFirstApplet problems - FOR THE LOVE OF EVERYTHING HOLY, PLEASE HELP, LOL

    Ok, I have a decent foundational understanding of programming concepts and web design. I decided to learn Java and it's frustrating me like crazy, running into problems at every turn.

    I'm just trying to get the simplest possible applet to work.

    My code is

    import java.awt.*;
    import java.applet.Applet;

    public class MyFirstApplet extends Applet {
    public void paint (Graphics g) {
    g.drawString("This is my first Applet!!!", 100, 25);
    }
    }

    My html is

    <HTML>
    <HEAD>
    <TITLE>My First Applet</TITLE>
    <BODY>
    <CENTER>
    <APPLET CODE = 'MyFirstApplet.class' WIDTH = 100 HEIGHT = 25 </APPLET>
    </CENTER>
    </BODY>
    </HTML>

    I have Windows 7 Ultimate 64-bit. I have both 32-bit and 64-bit java installed because I use firefox. After searching and searching, I finally realized I compiled this with the 64-bit Java(if thats correct? and if that matters?) and I was trying to run it in Firefox(32-bit) and Internet Explorer(32-bit version). I opened 64-bit IE and something finally happened but all it showed was the word "This ".

    What in the world am I doing wrong?

    [EDIT - I just now realized that if I zoom waaaaaay in, I can see the full text that I should.. in both firefox and IE. I don't have any unusual display settings though, and the text stays the same size, but just shows more with each increase in zoom. Is this normal? Do I just need to learn more about how applets are displayed before going any further trying to figure this out?]


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MyFirstApplet problems - FOR THE LOVE OF EVERYTHING HOLY, PLEASE HELP, LOL

    all it showed was the word "This ".
    Where was "This" shown on the screen? Was there enough space to the right of it for the rest of the String that is being drawn?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: MyFirstApplet problems - FOR THE LOVE OF EVERYTHING HOLY, PLEASE HELP, LOL

    Quote Originally Posted by Norm View Post
    Where was "This" shown on the screen? Was there enough space to the right of it for the rest of the String that is being drawn?
    It shows right at the top center of the browser display window. I'm not sure if you sent this before or after my edit on the original post, but it turns out it was a zoom problem. But I could still use an explanation if someone has one.

    I have a 20" widescreen set at 1600x900(medium zoon - 125%), nothing unusual as far as I know. This exact same tutorial was posted on several java tutorial websites and I made it the same to the letter.

    Is it just a bad tutorial?

    I assume the applet borders just need to be larger and/or the drawString method coordinates changed?

    While I'm at it anyway, I might as well ask this too. If my html(per the tutorial) draws a box for the applet that is 100x25.. and the drawString method places the text 100 pixels over and 25 down(or is it up?) from one corner of the applet box(I assume?), how could this work at all? even with the zoom?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MyFirstApplet problems - FOR THE LOVE OF EVERYTHING HOLY, PLEASE HELP, LOL

    I assume the applet borders just need to be larger and/or the drawString method coordinates changed?
    Did you try changing those and see what happened?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. I would love to meet a Friend who is very good in Java Programming.
    By Agent Austin in forum Member Introductions
    Replies: 0
    Last Post: May 4th, 2012, 06:51 PM
  2. Help lol
    By r_james14 in forum Java Theory & Questions
    Replies: 1
    Last Post: April 14th, 2012, 02:15 PM
  3. Frustrated lol.
    By stealthmonkey in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 14th, 2010, 10:02 PM
  4. LOL ROLF TTYL
    By JavaGreg in forum Member Introductions
    Replies: 3
    Last Post: August 5th, 2009, 02:13 PM