简体   繁体   中英

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?

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?

找到您的textarea滚动窗格,然后将可见性设置为false ,如下所示:

 jScrollPane4.setVisible(false);

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;

    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM