Swing/Java: How to use the getText and setText string properly

后端 未结 4 1587
青春惊慌失措
青春惊慌失措 2021-01-05 16:28

I\'m trying to make input nameField appear in a Label called label1 after a Button called button1 is clicked

4条回答
  •  轮回少年
    2021-01-05 17:09

    in your action performed method, call:

    label1.setText(nameField.getText());
    

    This way, when the button is clicked, label will be updated to the nameField text.

提交回复
热议问题