-
Notifications
You must be signed in to change notification settings - Fork 186
Closed
Description
Describe the bug
If I add a Skin listener and set the foreground color of a checkbox, it looks too compact.
To Reproduce
Run the following snippet on Windows 11 with 150% zoom level.
import java.io.*;
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class HiDpiTest {
public static void main(String[] args) throws IOException {
final Display display = new Display();
display.addListener(SWT.Skin, event -> {
if (event.widget instanceof Button button && (button.getStyle() & SWT.CHECK) != 0) {
button.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
}
});
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
addCheckbox(shell);
addCheckbox(shell).setSelection(true);
addCheckbox(shell).setGrayed(true);
final Button button = new Button(shell, SWT.PUSH);
button.setText("Button");
button.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
private static Button addCheckbox(Composite parent) {
final Button checkbox = new Button(parent, SWT.CHECK);
checkbox.setText("Checkbox");
checkbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
return checkbox;
}
}The checkbox text is too close to the box:

With older SWT builds before commit 5dd0c28) it looks correctly:

Environment:
- Select the platform(s) on which the behavior is seen:
-
- All OS
-
- Windows
-
- Linux
-
- macOS
- Additional OS info (e.g. OS version, Linux Desktop, etc)
Windows 11, 4k monitor, 150% zoom level
Version since
Eclipse or SWT version since when the behavior is seen [e.g. 4.23]
Workaround (or) Additional context
No known workaround.
Metadata
Metadata
Assignees
Labels
No labels