Make a Graphics2D class
I recently posted a topic on graphics 2D, and i got some awesome source code from lordkurt. Now i have a new problem.
I want to be able to make my own graphics class, that can be used from another program that i write. I want to be able to for instance do this "c.fillRect(x,y)". The one major problem that i am having is parameterising the method that i make. Can anyone help me out, i would be truly grateful.
P.S. lordkurt, if you want your stars from the previous topic, make any reply here. I ran out of duke points in the last topic
[558 byte] By [
Roqueforta] at [2007-11-27 6:13:09]

when i first started programming in ready we got a premade class called hsa. It had methods for drawing objects such as c.fillRect(x,y). I was making a really good ping pong game, but then i moved over to JGrasp which does not support the hsa console class. plus the hsa console was really bugged.
the c.fillOval(x,y,10,10) method made it easy to program a ball that could move. All you had to do was assign an int variable x and y to the method and increment them, and the oval would move.
could you explain that a little more. all that i have used swing for is to make a GUI and to use the JOptionPane.
i don't know much about the graphics class. But my main problem was adding parameters to the method "public void paint(Graphics g)" , because i couldn't do this "public void paint(Graphics g ,int x, int y)"
i'm really set on making my own class, it would just make my main program that much shorter, and i would be able to use it in the future. so if anyone can help me with some source code?
This is what i have made of the class and main program so far:
Class:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Game
{
JFrame jf;
public void window(int x,int y)
{
jf = new JFrame();
jf.setSize (500, 235);
jf.setLocation(300,200);
jf.setForeground(Color.green);
jf.setTitle ("Roquefort's attempt - <(''<)");
jf.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
Container con = jf.getContentPane();
Color col = new Color (204,230,227);
con.setBackground(col);
jf.setVisible(true);
}
public void painter(Graphics g,int x,int y)
{
g.setColor(Color.red);
g.fillRect(x,y,50,50);
}
}
and the main program
public class UseGame
{
public static void main (String[]args)
{
Game g = new Game();
g.window(800, 600);
g.paint();
}
}
sorry man, i cant help you with this, all the source codes that i gave you last time was not mine, i just found it 2 months ago when i'm starting to learn java.. i think you could do it to, just search and research.. maybe you could bump up with fine codes and information that you need...
good luck!!