How to resize Swing control which is inside SwingNode in JavaFX8?

前端 未结 3 1193
清歌不尽
清歌不尽 2020-12-21 00:16

How to resize Swing control which is inside SwingNode in JavaFX8?

Sometimes, I has controls resized inside SwingNode. But

3条回答
  •  没有蜡笔的小新
    2020-12-21 00:51

    I'm not sure if its exactly the same case, but seems related in the sense of getting swing components to size properly with the parent containers. In my case I had a SwingNode containing a JFreeChart (ChartPanel), which I simply couldn't get to resize properly when the parent frame (a border pane within a SplitPane) was itself resized. In the end i simply added a listener to the height/width properties:

    pane.widthProperty().addListener((w,o,n)->c.resizeChart((int)n.intValue(), (int)pane.getHeight()));
    pane.heightProperty().addListener((w,o,n)->c.resizeChart((int)pane.getWidth(), (int)n.intValue()));
    

    Nothing else I tried could emulate this. Thanks

提交回复
热议问题