FSp
FSp

Reputation: 1635

issue drawing aligned text using TextFlow and FlowPage

i'm drawing a multiline text label using a FlowPage object that contains a TextFlow object. the code of my label class is:

class TransitionLabel extends FlowPage {
    private TextFlow content;
    
    public TransitionLabel()
    {
        setForegroundColor(ColorConstants.white);
        setHorizontalAligment(PositionConstants.CENTER);
        content = new TextFlow();
        content.setOpaque(true);
        content.setText("");
        add(content);
    }
    
    public void setText(String content)
    {
        this.content.setText(content);
        revalidate();
        repaint();
    }
    
    public String getText()
    {
        return this.content.getText();
    }
    
}

when the control is refreshed (after modification) it ends up like the SEND labels in the screenshot below messy label texts.

am i doing something wrong? thanx for the help

PS the same screenshot can be found here

PPS i edited the method getPreferredSize that was irrelevant for the problem

Upvotes: 0

Views: 755

Answers (1)

Frettman
Frettman

Reputation: 2271

The FlowPage doesn't resize itself. It only tells the layout manager of its parent figure - upon request - what size it would like to have. I don't what layout manager is used, but maybe it doesn't resize your label. You could try to add

setSize(getPreferredSize());

in your setText(..) method before revalidating.

Upvotes: 0

Related Questions