Java Utililty Methods Draw Centered

List of utility methods to do Draw Centered

Description

The list of methods to do Draw Centered are organized into topic(s).

Method

voiddrawStringCentered(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);
voiddrawStringCentered(Graphics2D g, String text, int x, int y, int fontHeight, Color c)
draw String Centered
drawStringCentered(g, text, x, y, fontHeight, c, false);
voiddrawVerticallyCenteredText(String text, int margin, Rectangle rect, Graphics g2D, boolean rightJustify)
draw Vertically Centered Text
drawVerticallyCenteredText(text, margin, rect, g2D, rightJustify, false);