What you need to do is save JTextFieldas a private member AddressPanel. And in AddressPaneladd a method called hideTextField(). Then in this method the method setVisible(false)for the private JTextFieldmember is called.
The code might look something like this:
public class AddressPanel {
private JTextField textFieldToHide;
public void hideTextField(){
textFieldToHide.setVisible(false);
}
}
Then in the main frame use it like this:
addressPanel.hideTextField();
source
share