diff options
Diffstat (limited to 'NET/worlds/scape/ChangeAvatarImageButtons.java')
| -rw-r--r-- | NET/worlds/scape/ChangeAvatarImageButtons.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/NET/worlds/scape/ChangeAvatarImageButtons.java b/NET/worlds/scape/ChangeAvatarImageButtons.java new file mode 100644 index 0000000..56bd29e --- /dev/null +++ b/NET/worlds/scape/ChangeAvatarImageButtons.java @@ -0,0 +1,42 @@ +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); + } +} |