将metatag添加到此messagebubble

问题描述

在这里JavaFX WhatApp-Like ConversationView)找到了这个messagebubble设计,我正在尝试向它们添加一些元标记。我的意思是,我在消息提示框的右下角有时间和日期。

我目前仅以某种方式修改了气泡,使它们实际上符合我的“需求”。我现在的实际问题是我不知道如何在此气泡的右下角获得另一个标签

public class MessageBubble extends HBox
{

@Getter
@Setter
private UUID senderId;
@Getter
@Setter
private UUID messageId;

private final Color DEFAULT_SENDER_COLOR = GUI.getInstance().getCustomGreen();
private final Color DEFAULT_RECEIVER_COLOR = Color.WHITE;
private final Paint Meta_COLOR = Color.rgb(140,140,140);

private Background DEFAULT_SENDER_BACKGROUND,DEFAULT_RECEIVER_BACKGROUND;

private final String message;

private final SpeechDirection direction;

private Label displayedText,MetaText,dateText,usernameText;

public MessageBubble(String message,SpeechDirection direction)
{
    this.message = message;
    this.direction = direction;
    initialiseDefaults();
    setupElements();
}


private void initialiseDefaults()
{
    DEFAULT_SENDER_BACKGROUND = new Background(
            new BackgroundFill(DEFAULT_SENDER_COLOR,new CornerRadii(5,5,false),Insets.EMPTY));
    DEFAULT_RECEIVER_BACKGROUND = new Background(
            new BackgroundFill(DEFAULT_RECEIVER_COLOR,Insets.EMPTY));
}

private void setupElements()
{
    displayedText = new Label(message);
    displayedText.setPadding(new Insets(10));
    displayedText.setTextFill(Color.BLACK);
    displayedText.setWrapText(true);

    if (direction == SpeechDirection.LEFT)
    {
        configureForReceiver();
    } else
    {
        configureForSender();
    }
}

private void configureForSender()
{
    displayedText.setBackground(DEFAULT_SENDER_BACKGROUND);
    displayedText.setAlignment(Pos.CENTER_RIGHT);

    HBox container = new HBox(displayedText,MetaText);
    container.setPadding(new Insets(10,15,0));
    //Use at most 60% of the width provided to the SpeechBox for displaying the message
    container.maxWidthproperty().bind(widthproperty().multiply(0.6));

    getChildren().setAll(container);
    setAlignment(Pos.CENTER_RIGHT);
}

private void configureForReceiver()
{
    displayedText.setBackground(DEFAULT_RECEIVER_BACKGROUND);
    displayedText.setAlignment(Pos.CENTER_LEFT);

    HBox container = new HBox(displayedText);
    container.setPadding(new Insets(10,10,15));
    //Use at most 60% of the width provided to the SpeechBox for displaying the message
    container.maxWidthproperty().bind(widthproperty().multiply(0.6));
    getChildren().setAll(container);
    setAlignment(Pos.CENTER_LEFT);
}
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)