【发布时间】:2011-07-30 14:10:40
【问题描述】:
我需要在扩展JPanel 的某个类中绘制一些统计数据。目前的计划是使用paintComponent 和Graphics 类,如下所示:
public void paintComponent(Graphics g) {
super.paintComponent(g);
//create a rectangle to represent the outline of the graph
g.drawRect(300, 50, 400, 350);
//set up the datapoints
for(int i = 0; i < data.size(); i++) {
//put the datapoints where ever they need to go within this rectangle
g.drawOval(x, y, width, height);
}
}
出于某种原因,这很糟糕吗?更重要的是,是否有一些很棒的、易于使用的图形库我可以使用但不知道?
谢谢。
【问题讨论】:
标签: java swing graphics graph paintcomponent