https://www.formdev.com/flatlaf
第一步,加入dependency
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf-intellij-themes</artifactId>
<version>3.1.1</version>
</dependency>
第二步,加入代碼
try {
UIManager.setLookAndFeel(new FlatArcDarkIJTheme());
} catch (UnsupportedLookAndFeelException ex) {
Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
}
FlatLaf.setGlobalExtraDefaults(Collections.singletonMap("@accentColor", "#ffff00"));
Class<? extends LookAndFeel> lafClass = UIManager.getLookAndFeel().getClass();
try {
FlatLaf.setup(lafClass.newInstance());
} catch (InstantiationException ex) {
Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
}
FlatLaf.updateUI();