Redemptions Java Guide #1- Basics Using ObjectDraw!

Discussion in 'Programming General' started by Redemption, Feb 3, 2007.

Redemptions Java Guide #1- Basics Using ObjectDraw!
  1. Unread #1 - Feb 3, 2007 at 6:38 PM
  2. Redemption
    Joined:
    Jan 22, 2007
    Posts:
    429
    Referrals:
    0
    Sythe Gold:
    0

    Redemption Forum Addict
    Banned

    Redemptions Java Guide #1- Basics Using ObjectDraw!

    First, you will need a program that can start java apps and an installation of ObjectDraw. I recommend Textpad which is simple to use, or BlueJ which is a bit more complex. Textpad is better for beginners.

    ObjectDraw can be found here.
    TextPad can be found here.

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

    Code:
    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 ("Hello World!", 20, 20, canvas);
    
    }
    }
    ALWAYS REMEMBER JAVA IS CASE SENSITIVE!

    First, I'll explain this part:

    Code:
    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:

    Code:
    //This program will display text when you click on the canvas
    This 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:

    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:

    Code:
    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!

    Code:
    new Text ("Hello World!", 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:

    Code:
    }
    }
    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).

    THIS GUIDE IS PROPERTY OF ME, REDEMPTION, THE SOLE WRITER OF THE GUIDE. YOU MAY NOT COPY IT OR USE IT WITHOUT PERMISSON OR STATING THE NAME OF THE WRITER.
     
  3. Unread #2 - May 6, 2007 at 8:15 AM
  4. im the pjer
    Joined:
    Apr 29, 2007
    Posts:
    175
    Referrals:
    0
    Sythe Gold:
    0

    im the pjer Active Member
    Banned

    Redemptions Java Guide #1- Basics Using ObjectDraw!

    why are u banned?
     
  5. Unread #3 - May 6, 2007 at 8:15 AM
  6. im the pjer
    Joined:
    Apr 29, 2007
    Posts:
    175
    Referrals:
    0
    Sythe Gold:
    0

    im the pjer Active Member
    Banned

    Redemptions Java Guide #1- Basics Using ObjectDraw!

    is it fun?
     
  7. Unread #4 - May 6, 2007 at 9:22 AM
  8. irrelevant
    Joined:
    May 3, 2007
    Posts:
    225
    Referrals:
    0
    Sythe Gold:
    0

    irrelevant Active Member
    Banned

    Redemptions Java Guide #1- Basics Using ObjectDraw!

    *I sense an infraction for someone, for grace digging*

    *it's getting stronger*

    Irrl
     
< Web browser tutorial | Javculator v0.1 by 1337snak3 >

Users viewing this thread
1 guest


 
 
Adblock breaks this site