What should be used instead StartupUiUtil.isUnderDarcula()
Answered
The method StartupUiUtil.isUnderDarcula() is marked as Deprecated, instead of it's suggested to use StartupUiUtil.INSTANCE.isDarkTheme() but it's marked as an Internal API, and during plugin verification on Marketplace such plugin version is rejected.
My question is, what should I use for that?)
I want to load different files of *.css for HTMLEditorKit based on the theme.
Please sign in to leave a comment.
Okay, in the javadoc to com.intellij.util.ui.UIUtil#isUnderDarcula
I see that I can use either “JBColor#isBright()} to detect if current LaF theme is dark or bright”
or com.intellij.openapi.editor.colors.EditorColorsManager#isDarkEditor()
Any suggestions for my case?
The recommended approach is to use the
UIManager
to check for the current theme in a way that is not tied to internal APIs. You can use theUIManager.getLookAndFeel()
method to determine the theme and load the appropriate CSS files. Here's an example:java
Copy code
import javax.swing.*; public boolean isDarkTheme() { String lookAndFeel = UIManager.getLookAndFeel().getName().toLowerCase(); return lookAndFeel.contains("darcula") || lookAndFeel.contains("dark"); }