8322135: Printing JTable in Windows L&F throws InternalError: HTHEME is null

Reviewed-by: abhiscxk, honkar, aivanov
This commit is contained in:
Tejesh R 2024-04-25 04:31:55 +00:00
parent e6118ce784
commit 21480a7ae8
3 changed files with 17 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -100,21 +100,30 @@ public final class ThemeReader {
return xpStyleEnabled;
}
private static Long openThemeImpl(String widget, int dpi) {
Long theme;
private static long openThemeImpl(String widget, int dpi) {
long theme;
int i = widget.indexOf("::");
if (i > 0) {
// We're using the syntax "subAppName::controlName" here, as used by msstyles.
// See documentation for SetWindowTheme on MSDN.
setWindowTheme(widget.substring(0, i));
theme = openTheme(widget.substring(i + 2), dpi);
theme = getOpenThemeValue(widget.substring(i + 2), dpi);
setWindowTheme(null);
} else {
theme = openTheme(widget, dpi);
theme = getOpenThemeValue(widget, dpi);
}
return theme;
}
private static long getOpenThemeValue(String widget, int dpi) {
long theme;
theme = openTheme(widget, dpi);
if (theme == 0) {
theme = openTheme(widget, defaultDPI);
}
return theme;
}
// this should be called only with writeLock held
private static Long getThemeImpl(String widget, int dpi) {
return dpiAwareWidgetToTheme.computeIfAbsent(dpi, key -> new HashMap<>())

View File

@ -41,7 +41,7 @@ import javax.swing.table.DefaultTableModel;
/*
* @test
* @key headful
* @bug 8210807 8322140
* @bug 8210807 8322140 8322135
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @summary Test to check if JTable can be printed when JScrollPane added to it.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -22,7 +22,7 @@
*/
/*
* @test
* @bug 8257810
* @bug 8257810 8322135
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @summary Verifies if all pages are printed if scrollRectToVisible is set.