changeset 54:40911898ed23

Fix multiple border glitches.
author davidb
date Thu, 07 May 2020 14:05:40 -0700
parents 61a06e050bac
children f5faf70c7d10
files src/name/blackcap/exifwasher/HelpDialog.kt src/name/blackcap/exifwasher/Misc.kt src/name/blackcap/exifwasher/SettingsDialog.kt src/name/blackcap/exifwasher/ShowDialog.kt src/name/blackcap/exifwasher/WashDialog.kt
diffstat 5 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/name/blackcap/exifwasher/HelpDialog.kt	Thu May 07 12:33:52 2020 -0700
+++ b/src/name/blackcap/exifwasher/HelpDialog.kt	Thu May 07 14:05:40 2020 -0700
@@ -4,7 +4,6 @@
  */
 package name.blackcap.exifwasher
 
-import java.awt.Color
 import java.awt.Dimension
 import java.awt.Font
 import java.awt.event.ActionEvent
@@ -17,7 +16,6 @@
 import java.util.logging.Level
 import java.util.logging.Logger
 import javax.swing.*
-import javax.swing.UIManager
 import javax.swing.text.html.HTMLEditorKit
 import javax.swing.text.html.StyleSheet
 
@@ -66,9 +64,7 @@
         it.setEditable(false)
     }).apply {
         alignmentX = JScrollPane.CENTER_ALIGNMENT
-        border = BorderFactory.createCompoundBorder(
-            BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2),
-            UIManager.getBorder("ScrollPane.border") ?: BorderFactory.createLineBorder(Color.GRAY))
+        addBorder(BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2))
         verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
         horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
         preferredSize = Dimension(WIDTH, HEIGHT)
--- a/src/name/blackcap/exifwasher/Misc.kt	Thu May 07 12:33:52 2020 -0700
+++ b/src/name/blackcap/exifwasher/Misc.kt	Thu May 07 14:05:40 2020 -0700
@@ -13,6 +13,7 @@
 import java.awt.Toolkit
 import java.awt.event.MouseEvent
 import javax.swing.*
+import javax.swing.border.Border
 import javax.swing.table.TableColumnModel
 import kotlin.annotation.*
 import kotlin.properties.ReadWriteProperty
@@ -219,3 +220,13 @@
     }
 }
 
+/**
+ * Add a border to a JComponent. The new border is in addition to (and outside
+ * of) whatever existing standard border the component had.
+ */
+fun JComponent.addBorder(b: Border) {
+	if (border == null)
+		border = b
+	else
+		border = BorderFactory.createCompoundBorder(b, border)
+}
--- a/src/name/blackcap/exifwasher/SettingsDialog.kt	Thu May 07 12:33:52 2020 -0700
+++ b/src/name/blackcap/exifwasher/SettingsDialog.kt	Thu May 07 14:05:40 2020 -0700
@@ -218,7 +218,7 @@
 
         private val toAdd = JTextField(40).apply {
             alignmentX = CENTER_ALIGNMENT
-            border = BorderFactory.createEmptyBorder(BW, BW, BW, BW)
+            addBorder(BorderFactory.createEmptyBorder(BW, BW, BW, BW))
         }
 
         private val cancelButton = JButton("Cancel").also {
@@ -330,7 +330,7 @@
                     layout = BoxLayout(this, BoxLayout.Y_AXIS)
                     add(JScrollPane(wlSelector).apply {
                         alignmentX = CENTER_ALIGNMENT
-                        border = BorderFactory.createEmptyBorder(BW, BW, BW, BW)
+                        addBorder(BorderFactory.createEmptyBorder(BW, BW, BW, BW))
                         verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
                         horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
                     })
--- a/src/name/blackcap/exifwasher/ShowDialog.kt	Thu May 07 12:33:52 2020 -0700
+++ b/src/name/blackcap/exifwasher/ShowDialog.kt	Thu May 07 14:05:40 2020 -0700
@@ -94,7 +94,7 @@
             layout = BoxLayout(this, BoxLayout.Y_AXIS)
             add(JScrollPane(myTable).apply {
                 alignmentX = JScrollPane.CENTER_ALIGNMENT
-                border = BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2)
+                addBorder(BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2))
                 verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
                 horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
                 preferredSize = Dimension(WIDTH, HEIGHT)
--- a/src/name/blackcap/exifwasher/WashDialog.kt	Thu May 07 12:33:52 2020 -0700
+++ b/src/name/blackcap/exifwasher/WashDialog.kt	Thu May 07 14:05:40 2020 -0700
@@ -253,7 +253,7 @@
                 border = BorderFactory.createEmptyBorder(BW, BW, BW, BW)
                 add(JScrollPane(myTable).apply {
                     alignmentX = JScrollPane.LEFT_ALIGNMENT
-                    border = BorderFactory.createEmptyBorder(BW, BW, BW, BW)
+                    addBorder(BorderFactory.createEmptyBorder(BW, BW, BW, BW))
                     verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
                     horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
                     preferredSize = Dimension(WIDTH, HEIGHT)