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());
Also in Java:
- java vs javascript
- sort array java
- string to long java
- number to string java
- java random number between 100 and 999
- java sleep in code
- Display double in decimal places java
- how to make a copy of an array java
- write a java program to check whether given number is binary or not
- how make a final variable in java
- how to write a java for loop?
- imageview.setbackground
- bitwise operator in java
- java max
- get spring application context
- how to change actionbar color in android programmatically
- java pass arraylist by value
- java remove duplicates
- how to compare two maps in java
- dataframe to dict without index
- change button color java swing
- java add element to existing array
- lopp array java
- como detener un void java