chore: improve flatlaf

This commit is contained in:
hstyi
2025-07-05 15:52:06 +08:00
committed by hstyi
parent 2986a9cc46
commit 939d6a1fd7
2 changed files with 12 additions and 13 deletions

View File

@@ -173,7 +173,6 @@ class ApplicationRunner {
private fun setupLaf() {
System.setProperty(FlatSystemProperties.USE_WINDOW_DECORATIONS, "${SystemInfo.isLinux || SystemInfo.isWindows}")
System.setProperty(FlatSystemProperties.USE_ROUNDED_POPUP_BORDER, "false")
if (SystemInfo.isLinux) {
JFrame.setDefaultLookAndFeelDecorated(true)
@@ -197,12 +196,12 @@ class ApplicationRunner {
themeManager.change(theme, true)
if (Application.isBetaVersion()) {
FlatInspector.install("ctrl shift X")
}
UIManager.put(FlatClientProperties.FULL_WINDOW_CONTENT, true)
UIManager.put(FlatClientProperties.USE_WINDOW_DECORATIONS, false)
UIManager.put("TitlePane.useWindowDecorations", false)
UIManager.put("Component.arc", 5)
UIManager.put("TextComponent.arc", UIManager.getInt("Component.arc"))
@@ -213,7 +212,6 @@ class ApplicationRunner {
UIManager.put("Dialog.width", 650)
UIManager.put("Dialog.height", 550)
if (SystemInfo.isMacOS) {
UIManager.put("TabbedPane.tabHeight", UIManager.getInt("TitleBar.height"))
} else if (SystemInfo.isLinux) {
@@ -231,15 +229,21 @@ class ApplicationRunner {
UIManager.put("Table.rowHeight", 24)
UIManager.put("Table.focusCellHighlightBorder", FlatTableCellBorder.Default())
UIManager.put("Table.focusSelectedCellHighlightBorder", FlatTableCellBorder.Default())
UIManager.put("Table.selectionArc", UIManager.getInt("Component.arc"))
UIManager.put("Tree.rowHeight", 24)
UIManager.put("Tree.background", DynamicColor("window"))
UIManager.put("Tree.selectionArc", UIManager.getInt("Component.arc"))
UIManager.put("Tree.showCellFocusIndicator", false)
UIManager.put("Tree.repaintWholeRow", true)
// Linux 更多的是尖锐风格
if (SystemInfo.isMacOS || SystemInfo.isWindows) {
UIManager.put("Tree.selectionArc", UIManager.getInt("Component.arc"))
UIManager.put("List.selectionArc", UIManager.getInt("Component.arc"))
UIManager.put("ComboBox.selectionArc", UIManager.getInt("Component.arc"))
UIManager.put("Table.selectionArc", UIManager.getInt("Component.arc"))
UIManager.put("MenuBar.selectionArc", UIManager.getInt("Component.arc"))
UIManager.put("MenuItem.selectionArc", UIManager.getInt("Component.arc"))
}
}

View File

@@ -10,7 +10,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.slf4j.LoggerFactory
import java.util.function.Consumer
import javax.swing.PopupFactory
import javax.swing.SwingUtilities
import javax.swing.UIManager
@@ -118,11 +117,7 @@ internal class ThemeManager private constructor() {
private fun immediateChange(classname: String) {
try {
val oldPopupFactory = PopupFactory.getSharedInstance()
UIManager.setLookAndFeel(classname)
PopupFactory.setSharedInstance(oldPopupFactory)
} catch (ex: Exception) {
log.error(ex.message, ex)
}