1
我讀過,您可以調整大小(並通常轉換)可以使用SwingComponent.wrap(myComponent)獲取的包裝swing組件。我看不出如何。我看到返回的類型確實繼承了Resizable,但是如何設置min/maxHeight,h/vfill和其他屬性?在javafx中調整包裝的swing組件
我讀過,您可以調整大小(並通常轉換)可以使用SwingComponent.wrap(myComponent)獲取的包裝swing組件。我看不出如何。我看到返回的類型確實繼承了Resizable,但是如何設置min/maxHeight,h/vfill和其他屬性?在javafx中調整包裝的swing組件
這不是最好的解決方案,但它的工作原理。下面是示例代碼:
// Define the swing component, wrapper, and the scene.
var jPanel = new JPanel();
var swingWrapper = new SwingComponent.wrap(jPanel);
var scene = Scene{
width: 700
height: 500
content: [
swingWrapper
]
}
// Below are some triggers that fire off whenever the width or
// height of the scene change.
var currentWidth = bind scene.width on replace{
jPanel.setPreferredSize(new Dimension(scene.width,
scene.height));
swingWrapper.width = scene.width;
}
var currentHeight = bind scene.height on replace{
jPanel.setPreferredSize(new Dimension(scene.width,
scene.height));
swingWrapper.height = scene.height;
}
Stage {
title: "Some App"
scene: scene
}
下面是如何,你可以設置你需要的屬性的例子:
def swingComponent : SwingComponent = SwingComponent.wrap(new JPanel());
function setSwingComponentLayoutInfo():Void{
swingComponent.layoutInfo = LayoutInfo{
height: 200
width: 200
maxHeight: 400
maxWidth: 400
// ... other properties.
}
}
setSwingComponentLayoutInfo();
希望有所幫助。