启动时位于FlowPane工具栏末尾的徽标

时间:2019-01-27 14:48:22

标签: javafx

像我一样,调整大小后,我的徽标在我的FlowPane衍生工具栏的末尾显示得很好:

public class SocialUserDetailsImpl implements SocialUserDetails {

private static final long serialVersionUID = 1L;
private List<GrantedAuthority> list = new ArrayList<GrantedAuthority>();
private User user;

public SocialUserDetailsImpl(User user, List<String> roleNames) {
    this.user = user;

    for (String roleName : roleNames) {

        GrantedAuthority grant = new SimpleGrantedAuthority(roleName);
        this.list.add(grant);
    }
}

@Override
public String getUserId() {
    return this.user.getUserId() + "";
}

@Override
public String getUsername() {
    return user.getUserName();
}

@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
    return list;
}

@Override
public String getPassword() {
    return user.getPassword();
}

@Override
public boolean isAccountNonExpired() {
    return true;
}

@Override
public boolean isAccountNonLocked() {
    return true;
}

@Override
public boolean isCredentialsNonExpired() {
    return true;
}

@Override
public boolean isEnabled() {
    return this.user.isEnabled();
}

}

但是,我看不到徽标的缩写,因为width属性不好。我尝试了以下操作,但不起作用:

widthProperty().addListener((observable, oldWidth, newWidth) -> {
      positionLogo();
    }
);

工具栏设置方法:

m_primaryStage.setOnShown(e -> {
    m_primaryStage.getScene().getRoot().layout();
    m_toolbarSet.positionLogo();
});

1 个答案:

答案 0 :(得分:0)

这个想法很好,我刚刚设置onShown事件处理程序为时已晚-已经显示了舞台