Details
-
Bug
-
Resolution: Fixed
-
P3
-
8u40, 9
-
b153
-
x86
-
os_x
Description
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
JTable grid lines are positioned 1 pixel too high or too far left on a 2x HiDPI display.
The grid lines are drawn using drawLine at x-1 or y-1. This produces the intended effect on a 1x display, which is a 1 px line between x-1 and x or between y-1 and y. On a HiDPI display, the line is centered around x-1 or y-1. Should use drawRect.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a JTable that displays grid lines and has a non-opaque cell renderer. View on a HiDPI display.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The grid lines should be painted between the cell backgrounds.
ACTUAL -
The grid lines are painted 1 pixel too high or too far left, and are thus partially overlapped by the cell backgrounds.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
public class TestTableGrid
{
JFrame fr;
public TestTableGrid()
{
fr = new JFrame("Test Table Grid");
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() { return 10; }
public int getRowCount() { return 10;}
public Object getValueAt(int row, int col) { return new Integer(row*col); }
};
DefaultTableCellRenderer r = new DefaultTableCellRenderer();
r.setOpaque(true);
r.setBackground(Color.YELLOW);
JTable t = new JTable(dataModel);
t.setDefaultRenderer(Object.class, r);
t.setGridColor(Color.BLACK);
t.setShowGrid(true);
t.setShowHorizontalLines(true);
t.setShowVerticalLines(true);
fr.setContentPane(t);
fr.setLocation(200, 200);
fr.pack();
fr.setVisible(true);
}
public static void main(String args[])
{
new TestTableGrid();
}
}
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
JTable grid lines are positioned 1 pixel too high or too far left on a 2x HiDPI display.
The grid lines are drawn using drawLine at x-1 or y-1. This produces the intended effect on a 1x display, which is a 1 px line between x-1 and x or between y-1 and y. On a HiDPI display, the line is centered around x-1 or y-1. Should use drawRect.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a JTable that displays grid lines and has a non-opaque cell renderer. View on a HiDPI display.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The grid lines should be painted between the cell backgrounds.
ACTUAL -
The grid lines are painted 1 pixel too high or too far left, and are thus partially overlapped by the cell backgrounds.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
public class TestTableGrid
{
JFrame fr;
public TestTableGrid()
{
fr = new JFrame("Test Table Grid");
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() { return 10; }
public int getRowCount() { return 10;}
public Object getValueAt(int row, int col) { return new Integer(row*col); }
};
DefaultTableCellRenderer r = new DefaultTableCellRenderer();
r.setOpaque(true);
r.setBackground(Color.YELLOW);
JTable t = new JTable(dataModel);
t.setDefaultRenderer(Object.class, r);
t.setGridColor(Color.BLACK);
t.setShowGrid(true);
t.setShowHorizontalLines(true);
t.setShowVerticalLines(true);
fr.setContentPane(t);
fr.setLocation(200, 200);
fr.pack();
fr.setVisible(true);
}
public static void main(String args[])
{
new TestTableGrid();
}
}
---------- END SOURCE ----------