tab space on a JLabel not showing - weird - Java

前端 未结 1 681
耶瑟儿~
耶瑟儿~ 2021-01-23 05:55

I\'m trying to update a JLabel with new text and I need this text to have tabed space.

This is my code:

public void setNewLabelTxt(String text)
{
    nam         


        
1条回答
  •  清歌不尽
    2021-01-23 06:09

    JLabel doesn't render \t in any special way (ie, it doesn't convert the \t to spaces before rendering it).

    Instead, you should use something like

    text = text.replaceAll("\t", "    ");
    

    Before applying it to the label.

    0 讨论(0)
提交回复
热议问题