Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to get the width and height of a string in java

String text = "Hello World";
Font font = new Font("Arial", Font.PLAIN, 12);
FontRenderContext frc = new FontRenderContext(new AffineTransform(), true, true);

int textwidth = (int)(font.getStringBounds(text, frc).getWidth());
int textheight = (int)(font.getStringBounds(text, frc).getHeight());
Comment

PREVIOUS NEXT
Code Example
Java :: bucket sort java 
Java :: debug keystore 
Java :: javascript remove specific character from string 
Java :: datentypen java 
Java :: android studio centering textview in relativelayout 
Java :: exit app android 
Java :: get number of lines in a file java 
Java :: java get files in directory 
Java :: max long 
Java :: random string generator java 
Java :: java random between 
Java :: register command spigot 
Java :: foreground java jframe 
Java :: how to check type of primitive value in java 
Java :: android studio visibility 
Java :: HTTP FAILED: java.net.UnknownServiceException: CLEARTEXT communication to ztdev.co.za not permitted by network security policy 
Java :: java find item in list by property 
Java :: libgdx move camera with touch 
Java :: java split first occurrence 
Java :: how to clear stringbuilder in java 
Java :: A horizontal line must be drawn through the diamond, centered vertically. • The message must be printed just above the line. • The message must be horizontally centered within the applet 
Java :: java string to int 
Java :: spigot run code asynhronously 
Java :: double parse jtextfield 
Java :: dialog box in java swing 
Java :: android run background service on startup 
Java :: java key pressed 
Java :: in a junit test how test if empty list is returned 
Java :: jlabel on the center of a jpanel 
Java :: add text to jlable 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =