|    
			
				06/02/2008, 08:52
			
			
			  | 
  |   |  |  |  Fecha de Ingreso: enero-2008 
						Mensajes: 48
					 Antigüedad: 17 años, 9 meses Puntos: 3 |  | 
  |  Re: URGENTE : Mouse dragged  
  gracias por tu respuesta.No utilizo nada de canvas,y mis lineas son puntos compuestos por pixeles mas gruesos...entonces lo veo dificil.Los puntos son un arraylist <Punto>
 //METODO MODELO AÑADIR PUNTOS
 
 public void añadirPuntos(Punto p)
 {
 ListaPuntos.add(p);
 this.setChanged();
 this.notifyObservers(p);
 }
 
 Te pongo el código:
 //DONDE PINTO
 
 this.addMouseMotionListener(new MouseMotionListener()
 {
 @Override
 public void mouseDragged(java.awt.event.MouseEvent e)
 {
 switch(Pizarra.option)
 {
 case 3://DIBUJAR PUNTOS DE LA LINEA
 
 modelo.añadirPuntos(new Punto(e.getX(),e.getY(),colorNormal));
 break;
 }
 }
 
 //Si cAMBIA UN PUNTO DIBUJAMOS SOLO ESE
 
 /****************************METODO PAINt***********************************/
 public void paint(Graphics g)
 {
 
 System.out.println("Estamos en el paint.Principo");
 Graphics realGraphics = g; // nos guardamos la referencia a g, puesto que a lo mejor la machacamos despues
 
 if (this.getIcon()!=null && doubleBuffer == null){
 doubleBuffer = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB);
 }
 if (modelo==null && this.getIcon()!=null){
 g = doubleBuffer.getGraphics();
 super.paint(g);
 }
 if (modelo!=null && (doubleBuffer == null || hasChanged))
 {
 if (doubleBuffer == null)
 {
 doubleBuffer = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB);
 }
 
 g = doubleBuffer.getGraphics();
 
 Graphics2D g2 = (Graphics2D) g;//hace un cast para pasarlo a este tipo
 
 if (whatChanged != null)//este if es basicamente para dibujar los puntos a mano alzada
 {
 // ha cambiado una cosa concreta, no hace falta pintar todo
 if (whatChanged instanceof Punto)
 {
 
 // se añadio un punto, solo pintamos entonces ese punto
 Punto pu = (Punto) whatChanged;
 
 if(pu.getSeleccionado()==true)
 {
 System.out.println("Estamos en el paint en whatChanged");
 
 g2.setColor(pu.getColor());
 g2.setColor(colorSelec);
 g2.fillRect(pu.getX(),pu.getY(),11,11);
 
 }
 else
 {
 System.out.println("Estamos en el paint en whatChanged y  entramos else de seleccionado");
 g2.setColor(getColorNormal());
 }
 g2.fillOval(pu.getX(), pu.getY(), 5, 5);
 }
 
 }
     |