【问题标题】:How to put the text of a JLabel under its icon如何将 JLabel 的文本放在其图标下
【发布时间】:2012-03-19 12:58:24
【问题描述】:

我试图将 JLabel 的文本放在它的图标下(居中)我可以得到这个

使用JLabel north = new JLabel("North")

我尝试在标签JLabel("<HTML><BR>North</HTML>") 中使用html,但它没有正确对齐。有什么建议?


【问题讨论】:

    标签: java swing user-interface graphics jlabel


    【解决方案1】:

    看这个:

    基本上,在你的情况下使用这个:

    north.setHorizontalTextPosition(JLabel.CENTER);
    north.setVerticalTextPosition(JLabel.BOTTOM);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-30
      • 1970-01-01
      • 1970-01-01
      • 2013-05-03
      相关资源
      最近更新 更多