我如何将使用JavaFX创建的自定义标签嵌入到现有Swing的JPanel中?
例如:
自定义JavaFX标签:
public class CustomJavaFXLabel extends Label{
public CustomJavaFXLabel(){
super();
setFont("blah blah blah");
setText("blah blah blah");
/*
*and so on...
*/
}
}
在 Swing 中存在的 JPanel
public class SwingApp(){
private JPanel jpanel;
public SwingApp(){
jpanel = new JPanel();
jpanel.add(new CustomJavaFXLabel()); //this line does not work
}
}
我得到的错误是:
The method add(Component) in the type Container is not applicable for argument (CustomJavaFXLabel)
我知道为了这个目的,最好使用JLabel来创建自定义标签。但是,由于某些限制,我需要使用FX来创建自定义标签。
谢谢。