JavaFX将超链接绑定到标签

时间:2016-04-15 08:13:18

标签: java javafx

我在JavaFX应用程序中使用MVP。

资源:

public class InfoStageResources{

     StringProperty lblBlogText;
     Hyperlink linkBlog;

     InfoStageResources() {
         this.lblBlogText = new SimpleStringProperty("link");
         this.linkBlog = new Hyperlink("link");
     }

}

控制器:

public class InfoStageController{
     private InfoStageView view;
     private InfoStageResources res;

     public void initView(){
          this.res = new InfoStageResources();
          this.view = new InfoStageView(this.res);

          this.initViewBindings();
     }

     private void initViewBindings(){
          this.view.lblBlog.textProperty().bind(this.res.lblBlogText);
          //this will not work
          this.view.lblBlog.textProperty().bind(this.res.linkBlog);
     }
}

查看

在我的InfoStageView中,只需初始化我的标签并设置我的视图。

如何将我的超链接绑定到我的标签上。我试了一些但没有成功。 我的StringProperty lblBlogText不可点击但很容易绑定。

我的目标:我想用链接打开浏览器。

1 个答案:

答案 0 :(得分:0)

我认为你在寻找

 this.view.lblBlog.textProperty().bind(this.res.linkBlog.textProperty());
相关问题