2011-11-30 1 views
2

에 드래그 점멸 : 드래그나는 그런 코드가 스윙

public class DpDropTargetListener implements DropTargetListener { 
    public void dragOver(final DropTargetDragEvent dtde) { 
     ... 
     if (dtde.getLocation().equals(container.getLastLocation())) { 
     return; 
     } 
     ...  
     Rectangle visRect = container.getVisibleRect(); 
     container.paintImmediately(visRect.x, visRect.y, visRect.width, visRect.height); 

     //prepare the image to paint, and paint it 
     ... 
     Graphics2D gr = (Graphics2D) container.getGraphics();    
     gr.drawImage(container.getDragImage(), AffineTransform.getTranslateInstance(
     x, y), null); 
     ... 
    } 
} 

그것은 지정된 이미지를 그릴해야합니다. 그러나이 이미지는 드래그 할 때 깜박입니다. 깜박임을 멈추게하려면 어떻게해야합니까?

답변

3

컨테이너의 paintComponent() 메소드를 덮어 씁니다. 드래그하는 동안 컨테이너의 이미지와 위치를 설정하고 보통을 호출하십시오. repaint();

+0

paintImmediately()를 repaint()로 바꿉니다. 컨테이너의 paintComponent() Methods를 재정의 (override)합니다. 아무것도 바뀌지 않았다. –

+0

SSCCE를 게시하십시오. – StanislavL