Scaling of ColorDialog breaks during dpi change. In this screenshot, it is 100 -> 150
Test Example:
public class ColorDialogTest {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("ColorDialog Example");
shell.setSize(300, 200);
GridData data = new GridData(GridData.FILL_BOTH);
shell.setLayoutData(data);
// Create a button to open the color dialog
Button button = new Button(shell, SWT.PUSH);
button.setText("Choose Color");
button.setBounds(50, 50, 100, 30);
// Add a listener to open the ColorDialog when button is clicked
button.addListener(SWT.Selection, event -> {
ColorDialog colorDialog = new ColorDialog(shell, SWT.APPLICATION_MODAL);
colorDialog.setText("Select a Color");
// Open the dialog and get the selected color
RGB selectedColor = colorDialog.open();
if (selectedColor != null) {
// Apply the selected color as the shell background
Color color = new Color(display, selectedColor);
shell.setBackground(color);
// Dispose of the color when done
shell.addListener(SWT.Dispose, e -> color.dispose());
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
Scaling of ColorDialog breaks during dpi change. In this screenshot, it is 100 -> 150
Test Example:
Run the example with the following VM Arguments