views:

47

answers:

2

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?

+2  A: 

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?

jowierun
Usually JTextArea is placed inside a JScrollPane, so most likely you are right - need to hide the JScrollPane instead of text area
ZloiAdun
+1  A: 

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;

    }
eugener