为什么我不能像这样在JLabel中换行

时间:2018-09-16 09:37:12

标签: jlabel

我想检查JLabel中有多少行。但是后来出了点问题,我无法在JLabel中换行。有人可以解释一下我在做什么错吗?

private void SetPlayersBoard() {
    playersBoard = new JLabel("h <br/>");
    playersBoard.setSize(400, 400);
    playersBoard.setLocation(50,100);
    playersBoard.setVisible(true);
    this.add(playersBoard);
    playersBoard.setOpaque(true);
    repaint();

    for(int i=0; i<20; i++)
        playersBoard.setText(playersBoard.getText() + playersBoard.getText());

    String myText = playersBoard.getText();

    playersBoard.setText("<html>" + myText + "</html>");

}

0 个答案:

没有答案