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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:57:33+00:00 2026-06-03T00:57:33+00:00

I create a jTable, and TableCellRenderer, TableCellEditor on it. I need to put there

  • 0

I create a jTable, and TableCellRenderer, TableCellEditor on it. I need to put there editable (with text/html context type) JEditorPane. When i write some text inside and resize component, text disappear. What I doing wrong? Furthermore above this component I have got buttons with text edition: for example:

JButton bold = new JButton():
bold.setAction(new StyledEditorKit.BoldAction());

It is part of my custom model:

private JEditorPane editorTxtPane = new JEditorPane("text/html", "");
private JEditorPane rendererTxtPane = new JEditorPane("text/html", "");
private final JPanel editorPanel = new JPanel();
private final JPanel rendererPanel = new JPanel();
private final ArrayList<FocusListener> editorFocusListeners = new ArrayList<FocusListener>();

public SampleModel() {
    super();

    rendererTxtPane.setContentType("text/html");
    editorTxtPane.setContentType("text/html");

    rendererPanel.add(initCellControls(rendererPanel, rendererLabel));
    rendererPanel.add(rendererTxtPane);

    editorPanel.add(initCellControls(editorPanel, editorLabel));
    JScrollPane sp = new JScrollPane(editorTxtPane);
    sp.setBorder(null);
    editorPanel.add(sp);

    editorTxtPane.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            super.focusGained(e);
            e.setSource(editorTxtPane);
            for (int i = editorFocusListeners.size() - 1; i >= 0; i--) {
                editorFocusListeners.get(i).focusGained(e);
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            super.focusLost(e);
            e.setSource(editorTxtPane);
            for (int i = editorFocusListeners.size() - 1; i >= 0; i--) {
                editorFocusListeners.get(i).focusLost(e);
            }
        }
    });
}

It is my editor and renderer methods:

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    Comment c = data.get(row);
    rendererTxtPane.setText(c.getComment());
    return rendererPanel;
}

@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    Comment c = data.get(row);
    c.setNeedSave(true);
    editorTxtPane.setText(c.getComment());
    return editorPanel;
}
  • 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-03T00:57:34+00:00Added an answer on June 3, 2026 at 12:57 am

    This is not how Editors and Renderers work. In particular, the editor is only valid while the cell is being edited. Your TableModel should store each row’s Document. After editing concludes, your model will be updated with the revised Document, as described here. You might compare what your doing with the example, which could form the basis of your sscce.

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

Sidebar

Related Questions

I want to create a JTable with a header inside some cells. But I
i made a class where i create my jtable. I have some issues because
I have a JTable and need to change some of it's properties, such as
I have a JTable where I display some string data formatted using html. I
I'm trying to create a jTable that, once a button is clicked, adds rows
I would like to create a JTable like the below picture: Which java class
I have a standard JTable with certain data inside. I would like to create
Hi if You put JComboBox in JTable and String[] array to JComboBox everything works
I'm not asking HOW to display a Component in a JTable, as there are
1.how to set Width JTable Cell fit to Width Value? 2.how to create JTable

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.