0

I am going to draw multiline text. Text is limited by width, it wouldn't fit there, so I'd like to how many lines would be there, i.e. I need height of rectangle. I have font variable in Java. How can I do that?

Stepan Yakovenko
  • 8,670
  • 28
  • 113
  • 206
  • are you using monospaced fonts? if so, you can look at your wrapper that how many characters on line 1 appears. then you can split your whole text to that number. this may give you the line numbers. – Muhammet Can Nov 26 '12 at 06:54

2 Answers2

1

Try this http://java-sl.com/tip_text_height_measuring.html it works if you reflect the text in JEditorPane/JTextPane.

StanislavL
  • 56,971
  • 9
  • 68
  • 98
1

Have a look at Measuring Text, in particular Drawing Multiple Lines of Text

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366