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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:38:42+00:00 2026-06-15T08:38:42+00:00

I am trying to display HTML text inside a JTable’s cell but the scrollbars

  • 0

I am trying to display HTML text inside a JTable’s cell but the scrollbars arent showing up at all. Below is my code…

public class TableCellTextRenderer {

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,     
        boolean hasFocus, int row, int column) {

        final JTextPane jtextPane = new JTextPane();
        JScrollPane scrollPane = new JScrollPane(jtextPane);
        scrollPane.setPreferredSize(new Dimension(350,350));
        scrollPane.setVisible(true);
        jtextPane.setEditable(false);
        jtextPane.setAutoscrolls(true);
        jtextPane.setContentType("text/html");
        jtextPane.setText(myHtmlText);
        jtextPane.setVisible(true);
        jtextPane.setPreferredSize(new Dimension(350,350));

        //this setViewPort has no effect 
        scrollPane.setViewportView(jtextPane);

        jtextPane.setVisible(true);
        scrollPane.setAutoscrolls(true);
        scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        JPanel jpanel = new JPanel();
        jpanel.setVisible(true);
        jpanel.setPreferredSize(new Dimension(360, 360));
        jpanel.add(scrollPane);

        return jpanel;
    }
}

The scroll bars appear, but the scrolling handles dont appear. Can you please tell me what I am missing?

The table looks like this:

First row on jTable

  • 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-15T08:38:43+00:00Added an answer on June 15, 2026 at 8:38 am

    I’m afraid this is not going to work the way you’d want it to. The way JTables work is by obtaining a renderer component to draw the cell once, then cache it. In simplest terms, the component you’re returning is basically just used to draw the cell, but it does not work the way normal components do – for instance, it does not receive events. You can use a cell editor (which will receive events), but the user would have to select the cell manually.

    There are a couple of tricks you can use by installing custom mouse listeners, but this stuff will get very complicated. It’d probably be better to ask yourself if you’re really looking for a JTable (as opposed to a custom layout), or if it would perhaps be possible to embed a JavaFX table.

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

Sidebar

Related Questions

I'm trying to display HTML source code in my NSDocument based application. However, it
I am trying to display images inside my HTTP Web Server but I'm unable
Greetings! I've been trying to display some HTML with Java using JEditorPane . But
I'm trying to get what's inside a <div> with ID of display using $(#display).after(html);
I am trying to display 10 html pages as a single document,with 10 chapters.
I'm trying to display some large images with HTML img tags. At the moment
I'm trying to display the page title (html title) on the default.aspx page of
I'm trying to get an html page to display an XML file formatted with
I am trying to display an absolutely positioned div inside floating div. Here is
I am trying to center my navigation links inside the div but no matter

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.