Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
How to set minHeight and minWidth to a Window in TornadoFX?

I am using TornadoFX in my project. I have a root View which is a borderPane. I was able to find setPrefSize(1200.0, 720.0) and it works perfectly. However, by default the window is resizable, which user can resize it without any limits. Is there any property or method to set minHeight and minWidth of a window so that when resized, it stops at those limits?

So far I have tried these but none of them seem to work:

override val root = borderPane {
   minHeight = 400.0
   minWidth = 600.0
   setMinSize(600.0, 400,0)
   setWindowMinSize(600, 400) // this throws NPE
   addClass(loginScreen) // I even set properties in CSS
}


// StyleClass

loginScreen{
   minWidth = 600.px
   minHeight = 400.px
}

What is the proper way of setting minHeight and minWidth of a window in TornadoFX? And one more thing, how do I actually disable window resizing in TornadoFX, there is no property called isResizable? P.S. I am a super novice in Kotlin and in TornadoFX. Just started it today.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You are on the right track. The preferred size of the root component will become the initial size of the window. You can further configure a minimum size for the window, but you can't do it in the constructor of the UIComponent, since it is created before the actual window it will be shown in. For that reason, the onDock callback is a good place to configure the window with setWindowMinSize. If this is the main application window though, an even better strategy would be to override start and configure the minWidth and minHeigh properties for the Stage (which is a Window).

It is worth noting that the convenience function setWindowMinSize is only available if you override onDock in your UIComponent, since it's defined as a shortcut to set the min size of the currentStage for the UIComponent. If you override start, you have to manipulate the properties directly, like this:

class MyApp : App(MainView::class) {
    override fun start(stage: Stage) {
        with(stage) {
            minWidth = 600.0
            minHeight = 400.0
            super.start(this)
        }
    }
}

class MainView : View() {
    override val root = borderpane {
        setPrefSize(1200.0, 720.0)
    }
}

You can set isResizable = false on the Stage/Window in the start function as well if you want to prevent resizing.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda