0

在此处输入图像描述当我尝试制作直方图时,显示的矩形是分开的,如何使它们与另一个相邻(删除空格)

这是我的代码的一部分:

public DrawRectangle(int x, int y, int width, int height) {
    this.x = x;
    this.y = 100 - height - 1;
    this.width = width;
    this.height = height;

    box = new Rectangle();

    this.setPreferredSize(new Dimension(width + 1, 100));
}

public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    boite.setLocation(x, y);
    boite.setSize(width, height);
    g2.draw(box);
}
4

0 回答 0