2012-06-20 3 views
0

일부 구성 요소에는 JFrame이 있고 그래픽 개체에는 JPanel이 있습니다. 여기 Graphics2d 및 Jpanel

DrawingPanel() 
{ 
    DrawCellsComponent drawCellsComponent = new DrawCellsComponent(); 
    add(drawCellsComponent); 
} 

JPanel의

에 라인을 추가하려고 그리고하고있어 구성 요소의 코드입니다.

public void paintConponent(Graphics g) 
{ 
    Graphics2D g2 = (Graphics2D) g; 
    g2.setPaint(Color.RED); 
    g2.draw(new Line2D.Double(0, 0, 250, 250)); 
} 

JPanel에는 줄이 없습니다. 뭐가 문제 야?

답변

0

문제가 해결되었습니다. JComponent가 아닌 JPanel에 그려야합니다.