begginers tutorial

Discussion in 'Programming General' started by paladen, Jun 11, 2007.

begginers tutorial
  1. Unread #1 - Jun 11, 2007 at 12:53 AM
  2. paladen
    Joined:
    Jan 21, 2007
    Posts:
    1,633
    Referrals:
    1
    Sythe Gold:
    0

    paladen Guru
    Banned

    begginers tutorial

    reposted

    Here is the program I will break down and explain to you:


    import java.awt.*;
    import objectdraw.*;

    //This program will display text when you click on the canvas

    public class touchthewindow extends WindowController {

    public class onMouseClick (Location point){
    new Text ("You touched me!", 20, 20, canvas);

    }
    }ALWAYS REMEMBER JAVA IS CASE SENSITIVE!

    First, I'll explain this part:


    import java.awt.*;
    import objectdraw.*;This tells java that you want to import java.awt and the objectdraw library. These are the two basic includes you can really add onto a Java program. Without include files, Java would basically do nothing. Anyway, you don't really need to know much about these right now, they aren't all that important for beginners. All you need to know are the functions they can do, and some will be explained later in this guide.

    Next comes this code:



    //This program will display text when you click on the canvasThis is called a comment. Whatever you put after these two slashes, the program will totally disregard. An easy way to remember it is, people who slit their wrists will be ignored by the opposite gender. (Get it? //wrists... Teehee)

    Next comes this part of the code:


    public class touchthewindow extends WindowController {This code tells Java the name of the program (you must save the program as this name) and it lets Java know that it extends on the WindowController toolkit thing. The name of the program here is touchthewindow, and it extends on WindowController. Get it? You don't really need to know much about this yet, it won't be important for a while. The bracket is there to tell Java where the code for that part of the program is.

    After that comes the part where the program actually starts:


    public class onMouseClick (Location point){This tells java that when you click the mouse, the program after the bracket will initialize. Again, don't worry about "public class." "(Location point)" tells us that you can click anywhere on the screen. onMouseClick is from the objectdraw library that we included in the script earlier in the tutorial. Also in the objectdraw library are:

    onMouseEnter
    onMouseExit
    onMouseDrag

    Those are all I can think of right now, I'll probably remember more later. Again, the bracket tells the program where the code for that part of the program is.

    After that comes the actual code of the program. All that for ONE line of code!


    new Text ("You touched me!", 20, 20, canvas);This is pretty self explanatory. It will put new text on the screen. When you click, it will display "You touched me!" at the coordinates 20, 20 on the canvas. Don't forget the semi colon!

    Finally, the last bit of coding in the program:


    }
    }This tells the program to finish up. Remember those brackets you put earlier? This tells them that you finished up with the program.

    Well, you've finally learned some Java. Congratulations! You're now a nooby coder! When you're done, hit ctrl+1, then ctrl+3 (if you're using Textpad).
     
  3. Unread #2 - Jun 11, 2007 at 9:00 AM
  4. WoW Sucks
    Joined:
    Jan 21, 2007
    Posts:
    3,708
    Referrals:
    3
    Sythe Gold:
    0

    WoW Sucks Global Moderator
    Banned

    begginers tutorial

    Put the code i code boxes.
     
  5. Unread #3 - Jul 9, 2007 at 11:31 AM
  6. halo2fan
    Joined:
    Jan 21, 2007
    Posts:
    219
    Referrals:
    1
    Sythe Gold:
    0

    halo2fan Active Member

    begginers tutorial

    seriously, that is the messiest tutorial i have ever seen.
     
< NetBeans and Java | Where is a good Java 3D tutorial? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site