Java Graphics
Author |
Message |
CubicalGangster
|
Posted: Mon Nov 20, 2006 11:04 am Post subject: Java Graphics |
|
|
I am just starting out in Java and I was curious to see what a simple program to draw a line or square or circle etc. would look like. is it anything remotely close to turing? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
wtd
|
Posted: Mon Nov 20, 2006 11:17 am Post subject: (No subject) |
|
|
You should not expect it to be much like Turing at all. That shouldn't discourage you, though. Just know that you'll have to adjust how you think about writing programs. |
|
|
|
|
 |
ericfourfour
|
Posted: Mon Nov 20, 2006 3:17 pm Post subject: (No subject) |
|
|
Well, there is only two things you will notice similar between graphics in Turing and Java. You call a method (procedure in Turing's case) and the parameters are the coordinates. |
|
|
|
|
 |
[Gandalf]

|
Posted: Mon Nov 20, 2006 4:10 pm Post subject: (No subject) |
|
|
Well, it matters on how you're going to go about actually drawing stuff to the screen. Say you were to use swing, which is a common way, it would look something like this:
Java: | import javax.swing.*;
public class SimpleGraphics extends JFrame {
public SimpleGraphics (int maxx, int maxy ) {
super ("Simple Graphics Program");
setSize (maxx, maxy );
setDefaultCloseOperation (JFrame. EXIT_ON_CLOSE);
setVisible (true);
}
public static void main (String[] args ) {
new SimpleGraphics (500, 500);
}
public void paint (Graphics g ) {
g. setColor(Color. blue);
g. fillOval(100, 100, 20, 20);
}
} |
Note that this is purely from memory, and I am extremely tired, so it is only a rough estimate of what it would look like. Doubt it compiles, but if it does, all the better.
From a beginners perspective, I think that it doesn't really look all that intimidating, but there are a lot of concepts involved in there to learn first. Also, it gets incrementally more complicated as you add stuff into the program. But if you know the main concepts behind it, then it's actually quite easy to learn.
Note: The above post did not neccessarily make sense at all and could potentially be one big lie. I'm really not sure. |
|
|
|
|
 |
|
|