java - How to adjust JLabel dimensions to fixed font and font size? -
this question has answer here:
- how calculate font's width? 6 answers
- calculate display width of string in java 4 answers
i trying make java swing application involves use of several jlabels. each jlabel have different set of text , font size, depending on program input. every label must take little excess space possible. how can calculate minimum possible width , height jlabel, given fixed string of text, fixed font, , variable font size? define minimum height , width smallest possible dimensions jlabel before "..." displayed in label. "..." auto-generated , indicates jlabel small text displayed.
for example: how narrow , short can jlabel contains text "hello world" written in 12 point tahoma font before label displays "..."?
jlabel label = new jlabel("hello world"); label.setfont(new font("tahoma", font.plain, 12)); label.setbounds(100, 100, ???, ???); //how calculate minimum possible width , height fit text?
Comments
Post a Comment