[英]Multi line label/area/pane in Java with Justified text [closed]
我有一个有趣的任务。 考虑长度未知的String content
。 我想用带有对齐文本的Font font
显示content
。 我需要知道如果指定width
它将占height
。 我想在屏幕中间显示此文本,但它必须具有width的width
。
因此,我想做如下事情。
//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);
我怎样才能做到这一点?
通常,辩护是通过其他方式进行的。
文本具有固定的高度,您可以通过以下方式之一调整文本的宽度:
如果您调整高度以使宽度正确,则文本中的每一行都将具有不同的高度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.