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 8755517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:52:27+00:00 2026-06-13T13:52:27+00:00

I need a JTable that has multilined cells, and converts multiple (in one cell)

  • 0

I need a JTable that has multilined cells, and converts multiple (in one cell) URLs into clickable hyperlinks and supports basic style manipulation (bold, italic, underline), which means I can edit the style during or after entering the text. I also need it to be able to save the styled cell content into database.
What is the easiest way to achieve this?

I already tried creating a custom cell editor (and sorted out the multiline issue), which uses JTextPane and added key listener to it that listens when “space” character is released and if the last word starts with “http://”, removes it from it’s document and adds it again as styled text with href attribute and blue color. I also added listeners which listen for mouse clicks on hyperlinks. It all works during edit, but when the cell loses focus all text becomes unstyled and black. Maybe because I’m using different renderer and editor, but I add the key listeners to the renderer also.
I’m also having huge problems saving and especially setting table cell values when closing and starting the app. Should I go on and try to get it to work this way, or should I go back and take a different approach, like maybe setting JTextPane’s content type to “text/html”. If I did this I don’t really know how I’ll convert URLs into hyperlinks as you type.

BTW, the editor extends AbstractCellEdit, while the renderer extends JTextPane.

Any help will be appreciated.

  • 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-13T13:52:28+00:00Added an answer on June 13, 2026 at 1:52 pm

    Robin answered you on the JTable part, and I will add about text.

    If you don’t need real HTML, i.e. with links like <a href="http://example.com">link text</a>, then you can use DefaultStyledDocument as the model for your cell. To make http-prefixed text appear as a link, set the color to blue and add underline attribute. (DefaultStyledDocument model is simpler than HTMLDocument.)

    To preserve formatting, you should store Document, the text model in Swing, for each cell.

    There’s no need to remove and re-insert the text to add styling. You can apply styling to the text already in the Document, use setCharacterAttributes method.

    And you can actually re-use the rendering engine of Swing text components to render your cells. You can fetch the root view for presentation using TextUI.getRootView(). The view hierarchy can render your text and help you translate mouse clicks into text Elements, which you can use to launch hyperlink.

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

Sidebar

Related Questions

I need to load database content into a JTable . Many times I search
I need to show multiple icons in a single column in JTable. I am
I want to store the results of reading lucene index into jTable, so that
I am trying to create a JTable that has a row header that looks
I need to have a JToggleButton (that has custom background) that contains a JPanel
Have an application that has a Jtable with the data held in RAM, the
I have an empty JTable, absolutely nothing in it. I need to dynamically generate
I have a list, which is need to be shown as data. But JTable
I have a JTable that stores the results of a database query, so far
I need to highlight a particular column header in a JTable.Is it possible to

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.