I have an interesting task. Consider a String content
with unknown length. I'd like to display content
with a Font font
with Justified text. I need to know what height
this would take up if I specify the width
. I want to display this text in the middle of the screen but it must have a width of width
.
Hence, I would like to do something such as the following.
//create a JTextPane or JTextArea
pane.setText(content);
pane.setFont(font);
//set the width of the pane here
//get the height of the full text block if its justified
pane.setLocation(screenWidth/2 - width/2, screenHeight/2, height/2);
How can I do this?
+ your text here + ")`, same / similair with `JTextPane/Editor`, no idea how to determine `numbers of rows` for `JLabel`, `JTextPane/Editor` returns that by default, no idea where is your issue
– mKorbel Dec 31 '12 at 19:49