Reputation: 2503
I want to put a WorldWindowGLJPanel
into a Pane, and I want to make it resizable, but I can't, even when I call resize
or setSize
method.
Here's what I'm doing :
wwd = new WorldWindowGLJPanel();
wwd.setPreferredSize(new java.awt.Dimension(300, 300));
wwd.setModel(new BasicModel());
swingNode = new SwingNode();
swingNode.setContent(wwd);
wwdPane = new Pane();
wwdPane.getChildren().add(swingNode);
Then I use this wwdPane
to display World Wind.
I want my world wind panel
to have the size of the pane which contains it, and I want to make this world wind panel
resizable.
I thought about give the size to my world wind panel
of my pane
with a setSize(PaneDimenson)
and then bind the size of my worldwindpanel with my pane , but the setSize
function doesn't work.
EDIT : I found an alternative solution by not using a pane, but directly the swingNode, the resize is now automatic. But if you want to use a pane there's still a problem, and you're force to use a group.
Upvotes: 13
Views: 997
Reputation: 2763
The setSize is working, try this code:
scene.widthProperty().addListener(new ChangeListener<Number>() {
@Override public void changed( ObservableValue<? extends Number> o, Number b, Number a ) {
Platform.runLater(new Runnable() {
public void run() {
wwd.setSize((int)(a.intValue()*0.5), wwd.getHeight());
}
});
or with Java8
scene.widthProperty().addListener((o,b,a)->Platform.runLater(()->
wwd.setSize((int)(a.intValue()*0.5), wwd.getHeight())));
But I couldn't make the resize work in my sample code, because the SwingNode somehow mess up the resizing, I think you should try the solution advised here.
Upvotes: 0