package NET.worlds.scape; import NET.worlds.console.Console; import NET.worlds.console.ImageButtons; import NET.worlds.console.ImageButtonsCallback; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Rectangle; class ChangeAvatarImageButtons extends ImageButtons { private static final int textBoxX = 0; private static final int textBoxY = 0; private static final int textBoxW = 177; private static final int textBoxH = 23; private static Font font = new Font(Console.message("AvatarFont"), 0, 12); private static int textWidth; private static int textX; private static int textY; private String text; public ChangeAvatarImageButtons(String texture, Rectangle[] rects, ImageButtonsCallback cb, String text) { super(texture, rects, cb); this.text = text; } @Override public void paint(Graphics g) { super.paint(g); g.setFont(font); g.setColor(Color.white); if (textWidth == 0) { FontMetrics fm = g.getFontMetrics(); textWidth = fm.stringWidth(this.text); textX = (177 - textWidth) / 2; textY = 23 - (23 - fm.getAscent()) / 2; } g.drawString(this.text, textX, textY); } }