Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9051619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:56:59+00:00 2026-06-16T12:56:59+00:00

I have an interesting task. Consider a String content with unknown length. I’d like

  • 0

I have an interesting task. Consider a String contentwith 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T12:57:00+00:00Added an answer on June 16, 2026 at 12:57 pm

    Normally, justification is done the other way around.

    The text has a fixed height, and you adjust the width of the text in one of the following ways:

    • Add spaces between the words. Easier, but not visually appealing.
    • Add space between the letters. This is called kerning.

    If you adjust the height so that the width is correct, every line in your text will have a different height.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interesting scenario. I have a task model which has a task
I have an interesting task here.. is it possible to read the current file
I have quite an interesting task at work - I need to find out
I have a small but interesting task here. I have a list of files
I have a string in the form, var k= '<html><div id=test>it is interesting</div></html>' ,
I have a very interesting task, which I don't know how to implement. I
I have an interesting problem, and my logic isn't up to the task. We
I have interesting task which requires me to download a dynamically generated file from
I have an interesting task: to write a program which captures input from the
I have the interesting task of doing some graphs using VB.NET. So far, everything

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.