Pixel length of String
1. awt
Font font = new Font("Verdana", Font.PLAIN, 10);
FontMetrics metrics = new FontMetrics(font) {
};
Rectangle2D bounds = metrics.getStringBounds("string", null);
int widthInPixels = (int) bounds.getWidth();
2. Swing
SwingUtilities.computeStringWidth( fontMetrics, stringToComputeTheWidth );
3. swt
Point pt = imageGC.stringExtent(string);