简短的问题,希望是简单的解决方案:
我有自己的 a 渲染器ListView
,没什么花哨的,它只是连接 aLabel
和Icon
。我的问题是,到目前为止,标签忽略了我的“\n”。我该如何改变呢?我想用两行来表示我提供的信息。
谢谢收听。
简短的问题,希望是简单的解决方案:
我有自己的 a 渲染器ListView
,没什么花哨的,它只是连接 aLabel
和Icon
。我的问题是,到目前为止,标签忽略了我的“\n”。我该如何改变呢?我想用两行来表示我提供的信息。
谢谢收听。
使用 html 作为标签。像这样:new JLabel("<html>line 1<br>line 2</html>");
scala> import java.awt._
scala> import javax.swing._
scala> val frame = new JFrame()
scala> frame.setVisible(true)
scala> frame.setPreferredSize(new Dimension(400,300))
scala> val l = new JLabel("abc\nefg")
scala> frame.getContentPane.add(l)
scala> frame.pack
scala> l.setText("<html>abc<br>def</html>")
使用 \n 不起作用,但<html>abc<br>def</html>
可以。