私には興味深い仕事があります。String content
長さが不明なを考えます。正当化されたテキストで表示content
したいと思います。を指定した場合、これが何を占めるかを知る必要があります。このテキストを画面の中央に表示したいのですが、幅が.Font font
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);
これどうやってするの?