How to set the text box does not appear in the frame

I use the Swing framework and I have one question.

The address bar is dynamically added to the main frame. I want to call a method visible(false)from the main frame in the address bar.

+3
source share
1 answer

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();
+3
source

Source: https://habr.com/ru/post/1750949/


All Articles