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

  • Home
  • SEARCH
  • 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 8014255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:52:37+00:00 2026-06-04T19:52:37+00:00

I have a JTable . One column holds a JPanel which contains some JLabels

  • 0

I have a JTable. One column holds a JPanel which contains some JLabels with ImageIcons. I have created a custom cell render and all works fine apart from the tool tip on the JLabel. When I mouse over any of these JLabels I need to show the Tooltip of that particular JLabel. Its not showing the tootlip of the JLabel.

Here is the CustomRenderer.

private class CustomRenderer extends
            DefaultTableCellRenderer implements TableCellRenderer {

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

            if (value != null && value instanceof List) {

                JPanel iconsPanel = new JPanel(new GridBagLayout());
                List<ImageIcon> iconList = (List<ImageIcon>) value;
                int xPos = 0;
                for (ImageIcon icon : iconList) {
                    JLabel iconLabel = new JLabel(icon);
                    iconLabel.setToolTipText(icon.getDescription());
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.gridy = 1;
                    gbc.gridx = xPos++;
                    iconsPanel.add(iconLabel, gbc);
                }
                iconsPanel.setBackground(isSelected ? table
                        .getSelectionBackground() : table.getBackground());
                this.setVerticalAlignment(CENTER);
                return iconsPanel;
            }
            return 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-04T19:52:38+00:00Added an answer on June 4, 2026 at 7:52 pm

    The problem is that you set tooltips on subcomponents of the component returned by your CellRenderer. To perform what you want, you should consider override getToolTipText(MouseEvent e) on the JTable. From the event, you can find on which row and column the mouse is, using:

    java.awt.Point p = e.getPoint();
    int rowIndex = rowAtPoint(p);
    int colIndex = columnAtPoint(p);
    

    From there you could then re-prepare the cell renderer, find which component is located at the mouse position and eventually retrieve its tooltip.

    Here is a snippet of how you could override JTable getToolTipText:

    @Override
    public String getToolTipText(MouseEvent event) {
        String tip = null;
        Point p = event.getPoint();
    
        // Locate the renderer under the event location
        int hitColumnIndex = columnAtPoint(p);
        int hitRowIndex = rowAtPoint(p);
    
        if (hitColumnIndex != -1 && hitRowIndex != -1) {
            TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex);
            Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex);
            Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false);
            component.setBounds(cellRect);
            component.validate();
            component.doLayout();
            p.translate(-cellRect.x, -cellRect.y);
            Component comp = component.getComponentAt(p);
            if (comp instanceof JComponent) {
                return ((JComponent) comp).getToolTipText();
            }
        }
    
        // No tip from the renderer get our own tip
        if (tip == null) {
            tip = getToolTipText();
        }
    
        return tip;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

column header not visible in my JTable i have created a JPanel and added
I have a JTable of which one column is pre-filled with 30min time slots
I have a JTable which uses a custom TableModel to display a series of
I have A jtable. (tablesummary). one of it's column is EXPIRY. i want to
We have a Java Swing application which contains components like JTable, JCombobox, JTextArea and
I have a JTable where one column occasionally has a fair amount of text
how can I get a JTable to layout some rows with just one column
I have one JTable which show list of book and it can be filtered
I have a JTable inside a JScrollPane. In one of the columns in the
My question like this: I have a JTable, I put a JProgressBar in one

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.