我正在使用这个非常简单的InfoOverlay
:
import javafx.application.Application;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.controlsfx.control.InfoOverlay;
public class MainApp extends Application
{
private InfoOverlay infoOverlay;
public static void main(String[] args)
{
launch(args);
}
public Node getPanel(Stage stage)
{
String imageUrl = getClass().getResource("/styles/duke_wave.png").toExternalForm();
ImageView image = new ImageView(imageUrl);
String info = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
+ "Nam tortor felis, pulvinar in scelerisque cursus, pulvinar at ante. "
+ "Nulla consequat congue lectus in sodales.";
infoOverlay = new InfoOverlay(image, info);
infoOverlay.setShowOnHover(false);
StackPane stackPane = new StackPane(infoOverlay);
return stackPane;
}
@Override
public void start(Stage stage) throws Exception
{
Scene scene = new Scene((Parent) getPanel(stage));
stage.setTitle("JavaFX and Maven");
stage.setScene(scene);
stage.show();
}
}
我想将VBox
或BorderPane
插入InfoOverlay(image, info)
。根据JavaDoc:只有这些默认构造函数:
InfoOverlay()
InfoOverlay(Node content, String text)
InfoOverlay(String imageUrl, String text)
你能帮我解决一下吗?