Jagadesh
Jagadesh

Reputation: 6807

how to hide a text area in java swing form?

i used textarea1.setVisible(false); but still i can see the border of the text area at run time. i want the textarea to be completely invisible

Can anyone help in this issue?

Upvotes: 0

Views: 11348

Answers (3)

Sankar
Sankar

Reputation: 11

Find your textarea scrollpane, then set the visibility to false, like this:

 jScrollPane4.setVisible(false);

Upvotes: 1

Eugene Ryzhikov
Eugene Ryzhikov

Reputation: 17369

You have to hide the scroll pane which your text area is sitting in. If for some reason you have no direct access to it here is the way to get it:

public static final JScrollPane getScrollPane( JComponent component ) {

         Container p = component .getParent();
         if (p instanceof JViewport) {
                Container gp = p.getParent();
                if (gp instanceof JScrollPane) {
                    return (JScrollPane)gp;
                }
         }
         return null;

    }

Upvotes: 1

Paul Jowett
Paul Jowett

Reputation: 6581

It sounds like you have a Panel around your text area since setVisible(false) should definitely hide the entire component. If so, make the panel invisible. Care to post some code so we can examine and help?

Upvotes: 3

Related Questions