在按钮Graphics2D
对象上执行一些自定义绘画时,我得到以下结果:
最左边的按钮未切换,另一个按钮已切换。如您所见,切换按钮有这些白色的“妊娠纹”。为什么这些在那里,我如何删除它们?
这是我用来绘制边框的代码:
// Draw border of button
if(!getModel().isSelected())
{
g2.fillRoundRect(2, 2, getWidth() - 5, getHeight() - 5, ARC_WIDTH, ARC_HEIGHT);
g2.setColor(Color.BLACK);
g2.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, ARC_WIDTH, ARC_HEIGHT);
g2.setColor(Color.WHITE);
g2.drawRoundRect(1, 1, getWidth() - 3, getHeight() - 3, ARC_WIDTH, ARC_HEIGHT);
g2.setColor(Color.WHITE);
g2.drawRoundRect(2, 2, getWidth() - 5, getHeight() - 5, ARC_WIDTH, ARC_HEIGHT);
g2.setColor(Color.BLACK);
g2.drawRoundRect(3, 3, getWidth() - 7, getHeight() - 7, ARC_WIDTH, ARC_HEIGHT);
}
else
{
g2.fillRoundRect(2, 2, getWidth() - 5, getHeight() - 5, ARC_WIDTH, ARC_HEIGHT);
g2.setColor(Color.BLACK);
g2.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, ARC_WIDTH, ARC_HEIGHT);
g2.setColor(Color.BLACK);
g2.drawRoundRect(1, 1, getWidth() - 3, getHeight() - 3, ARC_WIDTH, ARC_HEIGHT);
g2.setColor(Color.BLACK);
g2.drawRoundRect(2, 2, getWidth() - 5, getHeight() - 5, ARC_WIDTH, ARC_HEIGHT);
g2.setColor(Color.BLACK);
g2.drawRoundRect(3, 3, getWidth() - 7, getHeight() - 7, ARC_WIDTH, ARC_HEIGHT);
}