here is the inner class:
Expand|Select|Wrap|Line Numbers
- class MyLine{
- public void add(int xx1, int yy1, int xx2, int yy2){
- x1=xx1;
- x2=xx2;
- y1=yy1;
- y2=yy2;
- }
- public int getX1(){return x1;}
- public int getX2(){return x2;}
- public int getY1(){return y1;}
- public int getY2(){return y2;}
- }
Expand|Select|Wrap|Line Numbers
- public void mouseReleased(MouseEvent e){
- obj[i] = new MyLine();
- obj[i].add(x1,y1,x2,y2);
- i+=1;
- System.out.println(i+""+obj[0].getX1());
- repaint();
- }
here is the method of paint() that is called when i call the repaint() method
Expand|Select|Wrap|Line Numbers
- public void paint(Graphics g){
- for(int j=0 ; j<i ; j++){
- g.setColor(Color.red);
- g.drawLine(obj[j].getX1(),obj[j].getY1(),obj[j].getX2(),obj[j].getY2());
- }
- }