mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
fix: JPopupMenu overlapping with background
This commit is contained in:
@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory
|
|||||||
import java.awt.image.BufferedImage
|
import java.awt.image.BufferedImage
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.imageio.ImageIO
|
import javax.imageio.ImageIO
|
||||||
|
import javax.swing.JPopupMenu
|
||||||
import javax.swing.SwingUtilities
|
import javax.swing.SwingUtilities
|
||||||
|
|
||||||
class BackgroundManager private constructor() {
|
class BackgroundManager private constructor() {
|
||||||
@@ -41,6 +42,23 @@ class BackgroundManager private constructor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getBackgroundImage(): BufferedImage? {
|
fun getBackgroundImage(): BufferedImage? {
|
||||||
|
assertEventDispatchThread()
|
||||||
|
val bg = doGetBackgroundImage()
|
||||||
|
if (bg == null) {
|
||||||
|
if (JPopupMenu.getDefaultLightWeightPopupEnabled()) {
|
||||||
|
return null
|
||||||
|
} else {
|
||||||
|
JPopupMenu.setDefaultLightWeightPopupEnabled(true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (JPopupMenu.getDefaultLightWeightPopupEnabled()) {
|
||||||
|
JPopupMenu.setDefaultLightWeightPopupEnabled(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bg
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doGetBackgroundImage(): BufferedImage? {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (bufferedImage == null || imageFilepath.isEmpty()) {
|
if (bufferedImage == null || imageFilepath.isEmpty()) {
|
||||||
if (appearance.backgroundImage.isBlank()) {
|
if (appearance.backgroundImage.isBlank()) {
|
||||||
|
|||||||
@@ -152,8 +152,14 @@ class SettingsOptionsPane : OptionsPane() {
|
|||||||
backgroundImageTextField.isEditable = false
|
backgroundImageTextField.isEditable = false
|
||||||
backgroundImageTextField.trailingComponent = backgroundButton
|
backgroundImageTextField.trailingComponent = backgroundButton
|
||||||
backgroundImageTextField.text = FilenameUtils.getName(appearance.backgroundImage)
|
backgroundImageTextField.text = FilenameUtils.getName(appearance.backgroundImage)
|
||||||
|
backgroundImageTextField.document.addDocumentListener(object : DocumentAdaptor() {
|
||||||
|
override fun changedUpdate(e: DocumentEvent) {
|
||||||
|
backgroundClearButton.isEnabled = backgroundImageTextField.text.isNotBlank()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
backgroundClearButton.isFocusable = false
|
backgroundClearButton.isFocusable = false
|
||||||
|
backgroundClearButton.isEnabled = backgroundImageTextField.text.isNotBlank()
|
||||||
backgroundClearButton.icon = Icons.delete
|
backgroundClearButton.icon = Icons.delete
|
||||||
backgroundClearButton.buttonType = FlatButton.ButtonType.toolBarButton
|
backgroundClearButton.buttonType = FlatButton.ButtonType.toolBarButton
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user