how can you programmatically set the JSplitPane to hide the right/bottom component when OneTouchExpandable is set to true?

前端 未结 5 1028
遥遥无期
遥遥无期 2021-01-06 06:30

In a JSplitPane, you have the setOneTouchExpandable method which provides you with 2 buttons to quickly fully hide or full show the JSplitPan

5条回答
  •  不思量自难忘°
    2021-01-06 06:39

    Working around the problem that setDividerLocation(1.0) doesn't work until the frame has become displayable, one can use an AncestorListener:

    sp.addAncestorListener(new AncestorListener {
      def ancestorAdded  (event: AncestorEvent): Unit = sp.setDividerLocation(1.0)
    
      def ancestorRemoved(event: AncestorEvent): Unit = ()
      def ancestorMoved  (event: AncestorEvent): Unit = ()
    })
    

提交回复
热议问题