Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

get string size on screen

import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;

...

String text = "Hello World";
AffineTransform affinetransform = new AffineTransform();     
FontRenderContext frc = new FontRenderContext(affinetransform,true,true);     
Font font = new Font("Tahoma", Font.PLAIN, 12);
int textwidth = (int)(font.getStringBounds(text, frc).getWidth());
int textheight = (int)(font.getStringBounds(text, frc).getHeight());
Comment

PREVIOUS NEXT
Code Example
Java :: java binary exponentiation 
Java :: Java Change ArrayList Elements 
Java :: Java Add elements to a HashMap 
Java :: how to get length of 2d array java 
Java :: java binary tree 
Java :: single level inheritance in java 
Java :: android how to know when snackbar is done 
Java :: what is method in java 
Java :: encryption 
Java :: java @override annotation 
Java :: map.put in java 
Java :: spring mvc 
Java :: spring boot prerequisites 
Java :: extends class in java 
Java :: types of exception in java 
Java :: what is deserialization in java 
Java :: java mahout get clusters centers 
Java :: java evaluate two expressions in if statemenmt 
Java :: kingkaihockey 
Java :: assign a random number in a set without replacement javva 
Java :: connect as SYSDBA java 
Java :: how to repeat string in java 
Java :: param vishisht seva medal 
Java :: Copying value from one input field to another input field using checkbox 
Java :: Java Catching base exception class only 
Java :: Show the difference between this() and super() with help of a code 
Java :: Creating Hashmap from Treemap 
Java :: number guessing game in java using oops 
Java :: Was ist ein String in java 
Java :: a to double 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =