RFR: 8279614: The left line of the TitledBorder is not painted on 150 scale factor [v3]
lukeu
duke at openjdk.java.net
Wed Mar 16 01:12:37 UTC 2022
On Mon, 14 Mar 2022 16:15:47 GMT, Alisen Chung <achung at openjdk.org> wrote:
>> Changed the drawing area to be increased by 0.5 on the left side to prevent clipping
>
> Alisen Chung has updated the pull request incrementally with one additional commit since the last revision:
>
> added functions for drawing border, fixed translate
OK after many hours of "bash"ing, I've convinced the JDK, cygwin and VS-2017 to play nicely again :-)
My suspicions were close: the lines jump apart, rather than overlap at 125%, and jiggle between 1 & 2px at 175%. The following screenshot is with the patched code at 125% display scaling on Windows, then zoomed in 3x:

Each subsequent titled border is offset 1 extra pixel (as given in the code) to the right, and you can see only the 3rd lets the background between the lines on the left side, at this particular splitter position. If it might be of use, here's my interactive test harness:
import java.awt.*;
import javax.swing.*;
public class Test {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Test()::run);
}
private void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
var frame = new JFrame();
frame.getContentPane().add(createSplitters());
frame.setSize(new Dimension(800, 600));
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
private JSplitPane createSplitters() {
return createSplit(
JSplitPane.HORIZONTAL_SPLIT,
new JPanel(),
createSplit(
JSplitPane.VERTICAL_SPLIT,
new JPanel(),
createTestArea()));
}
private JSplitPane createSplit(int dir, JComponent left, JComponent right) {
var split = new JSplitPane(dir, true, left, right);
split.setDividerLocation(200);
return split;
}
private Box createTestArea() {
Box box = Box.createVerticalBox();
box.add(createBorderedCheckbox(1));
box.add(createBorderedCheckbox(2));
box.add(createBorderedCheckbox(3));
return box;
}
private JComponent createBorderedCheckbox(int i) {
JPanel childPanel = new JPanel(new BorderLayout());
childPanel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(0, i, 0, 0),
BorderFactory.createTitledBorder("Title " + i)));
childPanel.add(new JCheckBox(), BorderLayout.CENTER);
childPanel.setBackground(new Color(190, 190 + 20 * i , 190));
return childPanel;
}
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/7449
More information about the client-libs-dev
mailing list