From fce62342b9c5611b37e95afe3bfde3133bcb8c37 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:21:20 +0000 Subject: Fix main bar button text positioning git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@277 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../at/asit/pdfover/gui/controls/MainBarButton.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'pdf-over-gui/src/main/java/at') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java index 95935c89..484f5e28 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java @@ -306,12 +306,6 @@ public abstract class MainBarButton extends Canvas { // e.gc.fillGradientRectangle(0, 1, width, height / 4, true); if (this.image == null) { - int textlen = 0; - - if (this.getText() != null) { - textlen = this.getText().length(); - } - Color current = e.gc.getForeground(); if(this.getActive() && this.isEnabled()) { @@ -326,17 +320,13 @@ public abstract class MainBarButton extends Canvas { this.getTextsize(), e.gc.getFont().getFontData()[0].getStyle()); + String text = this.getText(); e.gc.setFont(font); - - int texty = (height - e.gc.getFontMetrics().getHeight()) / 2; - - int textx = (width - e.gc.getFontMetrics().getAverageCharWidth() - * textlen) / 2; - + size = e.gc.stringExtent(text); + int texty = (height - size.y) / 2; + int textx = (width - size.x) / 2; textx = this.changeTextPosition(textx); - e.gc.drawText(this.getText(), textx, texty, true); - font.dispose(); e.gc.setForeground(current); -- cgit v1.2.3