java swing to count all controls

前端 未结 3 675
-上瘾入骨i
-上瘾入骨i 2021-01-27 10:59

How to count number of controls like JTextField, J Label and so on so..in java swing form designing,for example if we use only one textbox and one text field means i need the o

3条回答
  •  广开言路
    2021-01-27 11:23

    As they should all be inside your Container object you can use the getComponentCount() method to return you an int of the number of components.

    Container c;
    int count;
    count = c.getComponentCount();
    

提交回复
热议问题