Here you can find the source of drawRightJustifiedText(String text, int right, int y, Graphics g)
Parameter | Description |
---|---|
text | a parameter |
right | a parameter |
y | a parameter |
g | a parameter |
public static void drawRightJustifiedText(String text, int right, int y, Graphics g)
//package com.java2s; /*//from w w w . j av a2s . c om * Copyright (c) 2007-2012 The Broad Institute, Inc. * SOFTWARE COPYRIGHT NOTICE * This software and its documentation are the copyright of the Broad Institute, Inc. All rights are reserved. * * This software is supplied without any warranty or guaranteed support whatsoever. The Broad Institute is not responsible for its use, misuse, or functionality. * * This software is licensed under the terms of the GNU Lesser General Public License (LGPL), * Version 2.1 which is available at http://www.opensource.org/licenses/lgpl-2.1.php. */ import java.awt.*; import java.awt.geom.Rectangle2D; public class Main { /** * Draw a block of text right justified to the given location * * @param text * @param right * @param y * @param g */ public static void drawRightJustifiedText(String text, int right, int y, Graphics g) { FontMetrics fontMetrics = g.getFontMetrics(); Rectangle2D textBounds = fontMetrics.getStringBounds(text, g); int x = right - (int) textBounds.getWidth(); g.drawString(text, x, y); } }