Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

get string size

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 :: string length java 
Java :: java read fule get String 
Java :: path in spring form 
Java :: nth fibonacci number java using for loop 
Java :: different constructiors in java and what they do explained 
Java :: how to set the length to int array in java 
Java :: iterate through arraylist java 
Java :: how to get a set from a map in java 
Java :: GridLayout 
Java :: how to create a java txt file from programm 
Java :: java draw image 
Java :: private access modifiers 
Java :: why we use return method 
Java :: arraylist methods in java 
Java :: buy and sell stock 
Java :: syntax for java interfaces 
Java :: java eth 
Java :: Map - counting with map 
Java :: how todo a timeout test java 
Java :: h2 database spring boot create table application.properties 
Java :: session management in java spring boot for login logut 
Java :: Java extends and implements clause 
Java :: Transversal operation in java array 
Java :: reverse words in a string java 
Java :: null check in line java 
Java :: java arraylist max length 
Java :: using addition to multiply in java 
Java :: read only jtextfield 
Java :: conexion a mysql java 
Java :: which exception is thrown when java is out of memory 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =