【问题标题】:JavaFX bind a hyperlink to a labelJavaFX 将超链接绑定到标签
【发布时间】:2016-04-15 08:13:17
【问题描述】:

我在我的 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 不可点击但易于绑定。

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

【问题讨论】:

标签: java javafx


【解决方案1】:

我想你正在寻找

 this.view.lblBlog.textProperty().bind(this.res.linkBlog.textProperty());

【讨论】:

  • 是的,我也发现了这个,但是在我的 GUI 中只是一个“文本”而不​​是一个可点击的超链接 --> 现在我用超链接替换了我的标签,它可以工作了 :)
猜你喜欢
  • 1970-01-01
  • 2019-01-18
  • 2015-12-07
  • 2015-06-02
  • 1970-01-01
  • 2011-06-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多