如何在javafx中为标签添加字幕

时间:2015-10-27 07:25:31

标签: label javafx-8 subtitle

我需要一个带有副标题的标签,就像在这里一样 sample image

首先要考虑的是扩展GridPane并创建一个新的自定义窗格,如:

package Components.CustomLabel;

import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;

/**
 *
 * @author Aamir khan
 */
public class LabelWithSubTitle extends GridPane {

private final Label title = new Label();
private final Label subTitle = new Label();
private final ImageView thumb = new ImageView();

public LabelWithSubTitle(String titleString, String subString, Image thumb) {
    setTitle(titleString);
    setSubTitle(subString);
    setThumb(thumb);
    init();
}

private void setSubTitle(String sub) {
    subTitle.setText(sub);
}

private void setThumb(Image img) {
    thumb.setImage(img);
}

private void setTitle(String titleString) {
    title.setText(titleString);
}

private void init() {
    add(thumb, 0, 0, 1, 2);
    add(title, 1, 0);
    add(subTitle, 1, 1);
  }

}

我对此完全陌生,所以任何想法我怎么能实现这个目标?

0 个答案:

没有答案