Hey, im working on a program where i need to use the objects wich i get from the class "Borrehull" and store them inn an array.
import java.io.Serializable; public class Borrehull implements Serializable{ private int x; private int y; private int d; public Borrehull (int xkoord,int ykoord,int dim){ x=xkoord; y=ykoord; d=dim; } public int getx() { return x; } public int getd() { return d; } public int gety() { return y; } }
i am using a mouse actionlistener in the "main" program where i get the x and y koordinates when i click on the frame and the dim can i adjust with some grouped radiobuttons, here is the part og the "main" program where i get the x and y koordinates with getX() and getY():
class Tegne extends JPanel {//starts Tegne extends JPanel public Tegne() {//starts Tegne //create a mouselistener addMouseListener(new MouseListener(){ public void mouseClicked(MouseEvent arg0) { if (arg0.getButton()==1)//mouse left button { y=arg0.getY(); x=arg0.getX(); panel(); repaint(); } } public void mouseEntered(MouseEvent arg0){} public void mouseExited(MouseEvent arg0){} public void mousePressed(MouseEvent arg0){} public void mouseReleased(MouseEvent arg0){} }); }//ends Tegne protected void paintComponent(Graphics g){ super.paintComponent(g); g.setColor(Color.red); if(x>0|y>0 & diameter>0)g.fillOval(x,y ,diameter*2 ,diameter*2); } }//ends Tegne extends JPanel
all help will be much appreciated(: