如何使JLabel的文本扩展到另一行?
3 回答

ibeautiful
TA贡献1993条经验 获得超5个赞
您可以通过将HTML放入代码中来实现,因此:
JFrame frame = new JFrame();
frame.setLayout(new GridLayout());
JLabel label = new JLabel("<html>First line<br>Second line</html>");
frame.add(label);
frame.pack();
frame.setVisible(true);

智慧大石
TA贡献1946条经验 获得超3个赞
如果您希望jLabel Text自动调整大小,例如在可拉伸的gridbaglayout中,其大小足以将其文本放入html标签中,如下所示:
JLabel label = new JLabel("<html>First line and maybe second line</html>");
添加回答
举报
0/150
提交
取消