我有一个有趣的任务。考虑String content长度未知的 a。我想content用两端对齐Font font的文本显示。我需要知道如果我指定. 我想在屏幕中间显示此文本,但它的宽度必须为.heightwidthwidth
因此,我想做如下的事情。
//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);
我怎样才能做到这一点?