-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macos: reflective access by DarkLaf to constructor com.apple.laf.AquaLookAndFeel #53
Comments
Shouldn't occur anymore. |
I'm not sure how often Jigsaw is used, however, I guess that would be an error in a modular application. What do you think of getting the instance via |
For instance: final String systemLafClassName = UIManager.getSystemLookAndFeelClassName();
final LookAndFeel currentLaf = UIManager.getLookAndFeel();
if (systemLafClassName.equals(currentLaf.getClass().getName())) {
if (currentLaf instanceof BasicLookAndFeel) {
base = (BasicLookAndFeel) currentLaf;
} else {
base = new MetalLookAndFeel();
}
} else {
// Here can be a dance with UIManager.setLookAndFeel(systemLafClassName) + getLookAndFeel
try (ReflectiveWarningSuppressor sup = new ReflectiveWarningSuppressor()) {
final String name = UIManager.getSystemLookAndFeelClassName();
base = (BasicLookAndFeel) Class.forName(name).getDeclaredConstructor().newInstance();
}
} |
Yes this looks like a good solution. If |
What I mean is the following sequence seems to comply with UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
LookAndFeel systemLaf = UIManager.getLookAndFeel(); |
Though a rather heavy operation probably the best solution. I checked the implementation of |
Tried also this solution in FlatLaf some days ago. This had some downsides. First was that
Next problem was that the active LaF ( But there is a better solution. Since Java 9 there is a new method This is what I'm using in FlatLaf now: if( SystemInfo.IS_JAVA_9_OR_LATER ) {
Method m = UIManager.class.getMethod( "createLookAndFeel", String.class );
base = (BasicLookAndFeel) m.invoke( null, "Mac OS X" );
} else {
base = (BasicLookAndFeel) Class.forName( UIManager.getSystemLookAndFeelClassName() ).newInstance();
} This works fine without any warning. BTW congrats to the great DarkLaf launch. 👍 |
Thanks for the insight. Though the issue you are describing stems from initializing the base laf in
Thank you for the kind words :) |
:(
The text was updated successfully, but these errors were encountered: