FontRenderContext?context?=?g.getFontRenderContext();
Rectangle2D?bounds?=?font.getStringBounds(code,context);
//計算文件的坐標和間距
double?x?=?(width?-?bounds.getWidth())/2;
double?y?=?(height?-?bounds.getHeight())/2;
double?ascent?=?bounds.getY();
double?baseY?=?y?-?ascent;
g.drawString(code,(int)x,(int)baseY);
有人能幫我解釋一下下面代碼的坐標是怎么使用的嗎?謝謝
qq_bubulaxi_0
2018-08-06 14:32:09