我有一些组件的JFrame和JPanel,其中将是图形对象。我正在尝试在JPanel上添加行
DrawingPanel()
{
DrawCellsComponent drawCellsComponent = new DrawCellsComponent();
add(drawCellsComponent);
}这是组件的代码。
public void paintConponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
g2.setPaint(Color.RED);
g2.draw(new Line2D.Double(0, 0, 250, 250));
}JPanel上没有任何线路。有什么问题吗?
发布于 2012-06-21 01:42:28
问题解决了。只需在JPanel中绘制,而不是在JComponent中绘制
https://stackoverflow.com/questions/11120295
复制相似问题