List of utility methods to do Draw Centered
void | drawStringCentered(Graphics graphics, String string, Rectangle area) draw String Centered Rectangle2D rect = graphics.getFontMetrics().getStringBounds(string, graphics); int xx = area.x + area.width / 2 - (int) ((rect.getWidth()) / 2); int yy = (int) (area.y + area.height / 2 + (rect.getHeight() / 2)); graphics.drawString(string, xx, yy); |
void | drawStringCentered(Graphics2D g, String text, int x, int y, int fontHeight, Color c) draw String Centered drawStringCentered(g, text, x, y, fontHeight, c, false); |
void | drawVerticallyCenteredText(String text, int margin, Rectangle rect, Graphics g2D, boolean rightJustify) draw Vertically Centered Text drawVerticallyCenteredText(text, margin, rect, g2D, rightJustify, false); |