how to set new text in JTextField after creation?

前端 未结 2 1757
北荒
北荒 2021-01-22 10:35

I have a jTextField , and I set it\'s value to a certain sum when I create the frame.
Here is the initiation code:

totalTextField.setText(
            itemsP         


        
相关标签:
2条回答
  • 2021-01-22 10:59

    Add a WindowListener to the frame. Then you can handle the windowActivated event and reset the text of the text field.

    See How to Write Window Listeners.

    0 讨论(0)
  • 2021-01-22 11:18

    Before setting the frame visible again, one should update the fields with the new values / states.
    something like:

    jTextField.setText("put your text here");  
    jRadioButton.setSelected(!isSelected());  
    .  
    /* update all you need */
    .  
    jFrame.setVisible(true);
    

    The frame will come up with the new values / states.

    0 讨论(0)
提交回复
热议问题