• Log in or sign up for an account here: https://www.sythe.org/login

Basic Programming Using ObjectDraw

Redemption

Forum Addict
Joined
Jan 22, 2007
Sythe Gold
0
Messages
429
Location
Wewt Town USA
Basic Programming 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.
 
Basic Programming Using ObjectDraw
Ok nice guide bit basic tho? suppose you wont ba able to repply cos ur banned oh well
 
Basic Programming Using ObjectDraw
Nice guide, quite basic but also shame your banned.
 
Runescape Gamblingrunescape gambling
Back
Top