我在使用html在Eclipse UI Textfield中设置换行符时遇到问题 这就是我所拥有的:
tfCharacterDescription.setText(
"<html><div style='text-align: center;'>This is a human. <br>"
+ "The Humans has been good Warriors for centuries <br>"
+ "but they just cant get the hang of using a <br>"
+ "bow the right way.</html>"
);
我不确定这是不是这样做但我似乎找不到任何其他说法。
答案 0 :(得分:0)
JTextfield不支持HTML标签! 而是在JTextPane中使用:
JTextPane tfCharacterDescription = new JTextPane();
tfCharacterDescription.setBounds(12, 12, 320, 110); //set the size
tfCharacterDescription.setContentType("text/html");//This is essential!
tfCharacterDescription.setText(
"<html><div style='text-align: center;'>This is a human. <br>"
+ "The Humans has been good Warriors for centuries <br>"
+ "but they just cant get the hang of using a <br>"
+ "bow the right way.</html>"
);