Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

import java.awt.*;

public class Main {
    /**
     * Returns the height of the given component.
     *
     * @param c the component where the text is contained
     * @return the height of the text
     */
    public static int getStringHeight(Component c) {
        // get metrics from the graphics
        FontMetrics metrics = c.getFontMetrics(c.getFont());
        // get the height of a line of text in this font and render context
        int hgt = metrics.getHeight();
        // calculate the height of a box to hold the text with some padding.
        return hgt + 2;
    }
}