Create dialog with OS minimize, maximize, and close buttons

Hello,

I’m building a plugin that’s essentially hard-coded to validate a particular Java project at my company. This plugin gathers validation data from the code base, then displays it using my ValidationDialogBox, which extends DialogWrapper.

Now when I .show() this dialog box, it creates the modal and displays the info as expected. However, the modal does not have the “minimize”, “maximize”, or “close” OS buttons. I can manually resize the window, but there’s no way to change its z-position. I can’t hide this window behind my main code editing window. It’s forced to be on top.

My intent for this plugin is to have it run the validation, create the validation results window, then allow the user to operate both the “validation window” and the “editing the code window” independently.

For example, the GitCurrent FileShow History for Selection modal exhibits my desired window functionality. I would attach a screenshot to illustrate this, but it looks like new users can only attach a single piece of media to their topics :upside_down_face:

How would I implement this new window functionality? Would I need to rewrite my validation window in Kotlin UI DSL or something?

As far as I know, DialogWrapper can’t create non-modal windows.

I have used FrameWrapper to do this

Ex:

@Service(Level.PROJECT)
class DialogService(private val project: Project) : Disposable {
    private var someWindow: SomeWindow? = null

    @RequiresEdt
    fun showOrFocus() {
        val existing = someWindow?.takeUnless { it.isDisposed }
        if (existing != null) {
            existing.getFrame().toFront()
            existing.getFrame().requestFocus()
            return
        }

        val newSomeWindow = SomeWindow()
        Disposer.register(this, newSomeWindow)

        someWindow = newSomeWindow
        Disposer.register(newSomeWindow) {
            someWindow = null
        }

        newSomeWindow.show()
    }

    override fun dispose() {}

    private inner class SomeWindow : FrameWrapper(project) {
        override val dimensionKey: String = "custom.string.here.to.make.it.remember.size"

        init {
            closeOnEsc()

            title = "Title"
            component = createCenterPanel()
        }

        private fun createCenterPanel(): JComponent {
            return BorderLayoutPanel()
        }
    }

    companion object {
        fun getInstance(project: Project): DialogService = project.service()
    }
}

This is exactly what I need! I’ve never written Kotlin before. Time to wrestle with a new language. Thanks!

It doesn’t have to be in Kotlin, it can be in Java. This doesn’t use any Kotlin native API, I just defaulted to it for the example