或者显示文本框中键入的任何文本
// in either Capital or lowercase depending on the original
// letter changed. For example: CoMpUtEr will convert to
// cOmPuTeR and vice versa.
Switch.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e )
String characters = (SecondTextField.getText()); //String to read the user input
int length = characters.length(); //change the string characters to length
for(int i = 0; i < length; i++) //to check the characters of string..
{
char character = characters.charAt(i);
if(Character.isUpperCase(character))
{
SecondTextField.setText("" + characters.toLowerCase());
}
else if(Character.isLowerCase(character)) …Run Code Online (Sandbox Code Playgroud) 这是我的文本字段代码.当线条结束时它不会改变线条,但是继续继续,使框架看起来很奇怪.
我试图使用滚动窗格,但它没有帮助我.
JTextArea TextArea = new JTextArea(7,10);
gridConstraints.gridx = 0;
gridConstraints.gridy = 0;
TextPanel.add(TextArea, gridConstraints);
TextArea.setEditable(true);
Run Code Online (Sandbox Code Playgroud)