我想制作一个 Swing 程序来更新您所做的事情。它将所有信息写入不可编辑的 JTextField
。
例如:
You have changed the text to BLUE.
You have changed the text to RED.
问题是我无法将两条线分开。
我得到的是这样的:
You have changed the text to BLUE. You have changed the text to RED.
我试过的是:(这不起作用)
TF_BetInfo.setText(TF_BetInfo.getText() + "\nYou have changed the text to BLUE.");
TF_BetInfo.setText(TF_BetInfo.getText() + "\nYou have changed the text to RED.");
最佳答案
JTextField 不能有多行,你可以为此目的使用 JTextArea,代码也不会有太大不同,你仍然可以使用相同的代码,或者你可以
TF_BetInfo.append("\nyou have ...... ");
其中 TF_Betinfo 是 JTextArea 而不是 JTextField。
关于java - 如何在 JTextField 中创建一个新行来输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27698592/