diff src/name/blackcap/imageprep/RotateDialog.kt @ 6:9129ae110146

Window reshapes to avoid gratuitous scrollbars (as it should).
author David Barts <n5jrn@me.com>
date Fri, 17 Jul 2020 17:58:55 -0700
parents 09dcd475d1bf
children b5fcabce391f
line wrap: on
line diff
--- a/src/name/blackcap/imageprep/RotateDialog.kt	Fri Jul 17 17:11:43 2020 -0700
+++ b/src/name/blackcap/imageprep/RotateDialog.kt	Fri Jul 17 17:58:55 2020 -0700
@@ -7,6 +7,7 @@
 import java.awt.Graphics
 import java.awt.Graphics2D
 import java.awt.RenderingHints
+import java.awt.Toolkit
 import java.awt.event.ActionListener
 import java.awt.image.BufferedImage
 import java.io.File
@@ -20,8 +21,6 @@
 class RotateDialog(val file: File, initialImage: BufferedImage) : JDialog(Application.mainFrame) {
     private val BW = 9
     private val BW2 = BW * 2
-    private val MINWIDTH = 512
-    private val MINHEIGHT = 384
 
     private class DrawingPane(initialImage: BufferedImage) : JPanel() {
         var image: BufferedImage = initialImage
@@ -31,7 +30,11 @@
             repaint()
         }
 
-        override fun getPreferredSize() = Dimension(image.width, image.height)
+        override fun getPreferredSize(): Dimension {
+            val screen = Toolkit.getDefaultToolkit().screenSize
+            return Dimension(min(image.width, screen.width/4*3),
+                min(image.height, screen.height/4*3))
+        }
 
         override protected fun paintComponent(g: Graphics): Unit {
             g.drawImage(image, 0, 0, null)
@@ -76,6 +79,9 @@
             dispose()
         }
         drawingPane.image = rotatedImage
+        revalidate()
+        pack()
+        repaint()
     }
 
     init {