简体   繁体   中英

how to set components invisible in netbeans drag and drop design view

I want to set components invisible in the netbeans design view and then show then from coding when some event occurs. Is it possible?

When you create NewJFrameForm using Netbeans, In Design view you can drag and drop all the components available in palette.

In order to set initially invisible / hidden at starting you have to do it manually. Click on source above, Now you can see generated source of that frame you designed. You will see constructor as:

public NewJFrame() {
        initComponents();
    }

Generated itself. now you have to put your own code to update like in my case i will set invisible my compnents like:

jPanel1.setVisible(false);

OR

specific components:

jButton1.setVisible(false);
jToggleButton1.setVisible(false);
jLabel1.setVisible(false);

if prefer this like:

public NewJFrame() {
        initComponents();
        mySettings();
    }
public void mySettings(){
//Hide or set initial Values of components
}

在此处输入图片说明

Note:

all your generated code is in

    initComponents();

you can not edit it in source, have to do it in design view

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