我需要在某人的类中绘制一些统计数据,这些数据扩展了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);
    }
}
出于某种原因,这很可怕吗?更重要的是,是否有一些很棒的、易于使用的图形库我可以使用但不知道?
谢谢。