Skip to main content

Use javafx.ext.swing components where node expected

2 replies [Last post]
stevelaw
Offline
Joined: 2008-08-01
Points: 0

I'm confused as to the usage of the javafx.ext.swing components. Let's say I want to create a CustomNode, and use one of the javafx.ext.Swing comoponents, like the example below which uses javafx.ext.swing.Label. This does not work because a Label is not a Node object, and the compiler shows the following error. Is it possible to use a javafx.ext.swing component where a Node is expected? Thanks

found : javafx.ext.swing.Label
required: javafx.scene.Node
content: Label {

public class Example extends CustomNode {
public function create(): Node {
return Group {
content: Label {
text: "Test"
}
};
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexsch
Offline
Joined: 2007-07-12
Points: 0

[b]ComponentView [/b] class allows to put UI components to the Node hierarchy:

[code]
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.transform.*;
import javafx.scene.geometry.*;

import javafx.application.*;
import javafx.ext.swing.*;

public class Example extends CustomNode {
public function create(): Node {
return Group {
content: ComponentView {
transform: [ ]
component: Label{
text: "Test"
}
}
};
}
}

[/code]

stevelaw
Offline
Joined: 2008-08-01
Points: 0

Great, exactly what I was looking for. Thanks again!