-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
17
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
The bug is reproducible on Windows 10 with all JDKs from 9 to 17.
The bug is also present on Ubuntu 20.04
A DESCRIPTION OF THE PROBLEM :
When the cells of a JTable has the tooltips, the rendering not working properly.
When a cell tooltip disappears the cell behind the tooltip is not repainted correctly.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Move mouse over a cell of the last rows
2. Wait until tooltip is displayed
3. Move slowly the mouse to the top of the table
4. See blank areas in the table where the tooltips was disposed
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Window;
public class TableCellToolTipBug {
private TableCellToolTipBug() {
}
public static void main(String[] args) {
SwingUtilities.invokeLater(TableCellToolTipBug::run);
}
private static void run() {
Object[][] data = new Object[20][];
for( int i = 0; i < data.length; i++ ){
data[i] = new Object[]{i * 10000, i * 20000, i * 30000, i * 40000, i * 50000};
}
JTable table = new JTable(new DefaultTableModel(data, new String[]{"1", "2", "3", "4", "5"}));
table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component tableCellRendererComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
this.setToolTipText("<html>This is a very very long tooltip:<br><br> " + value.toString() + "</html>");
return tableCellRendererComponent;
}
});
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getTableHeader(), BorderLayout.NORTH);
panel.add(table);
JPanel anotherPanel = new JPanel(new BorderLayout());
anotherPanel.add(panel);
JDialog dialog = new JDialog((Window) null, "Table cell tooltip");
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.add(anotherPanel);
dialog.setSize(600, 400);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
If a cell is selected the problem seems not appears
FREQUENCY : always
The bug is reproducible on Windows 10 with all JDKs from 9 to 17.
The bug is also present on Ubuntu 20.04
A DESCRIPTION OF THE PROBLEM :
When the cells of a JTable has the tooltips, the rendering not working properly.
When a cell tooltip disappears the cell behind the tooltip is not repainted correctly.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Move mouse over a cell of the last rows
2. Wait until tooltip is displayed
3. Move slowly the mouse to the top of the table
4. See blank areas in the table where the tooltips was disposed
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Window;
public class TableCellToolTipBug {
private TableCellToolTipBug() {
}
public static void main(String[] args) {
SwingUtilities.invokeLater(TableCellToolTipBug::run);
}
private static void run() {
Object[][] data = new Object[20][];
for( int i = 0; i < data.length; i++ ){
data[i] = new Object[]{i * 10000, i * 20000, i * 30000, i * 40000, i * 50000};
}
JTable table = new JTable(new DefaultTableModel(data, new String[]{"1", "2", "3", "4", "5"}));
table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component tableCellRendererComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
this.setToolTipText("<html>This is a very very long tooltip:<br><br> " + value.toString() + "</html>");
return tableCellRendererComponent;
}
});
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getTableHeader(), BorderLayout.NORTH);
panel.add(table);
JPanel anotherPanel = new JPanel(new BorderLayout());
anotherPanel.add(panel);
JDialog dialog = new JDialog((Window) null, "Table cell tooltip");
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.add(anotherPanel);
dialog.setSize(600, 400);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
If a cell is selected the problem seems not appears
FREQUENCY : always
- duplicates
-
JDK-8270856 Insufficient repaint after JTable header multiline tooltip
-
- Closed
-