如何在 groovy swingbuilder 面板中获取所有组件名称?

how get all component name in groovy swingbuilder panel?

我试图在单击 groovy 面板中的按钮时获取所有组件名称

但我的命令没有获取所有组件;我如何在

中更正此代码

groovy

不知道怎么搞定

请帮我解决这个问题;

我正在使用 getcomponent() 命令,但没有获取面板的所有组件

我需要获取组件日期和 dat3e

import groovy.swing.SwingBuilder 
import groovy.beans.Bindable 
import static javax.swing.JFrame.EXIT_ON_CLOSE 
import java.awt.*
import groovy.transform.Field


    def swingBuilder = new SwingBuilder()
    swingBuilder.edt {  
        frame(title: 'Address',   id:"allx" ,size: [350, 230],
                show: true, locationRelativeTo: null,
                defaultCloseOperation: EXIT_ON_CLOSE) {
            borderLayout(vgap: 5)

            panel(constraints: BorderLayout.CENTER,   id:"allx2" ,
                    border: compoundBorder([emptyBorder(10), titledBorder('Enter your address:')])) {
                tableLayout {
    tr{ textField  id:"allx3"

      td {       textField  id:"date",text="01-01-18", columns: 10     } 

    }

    tr{  

      td {       textField  id:"dat3e",text="01-01-18", columns: 10     } 

    }
    }

     }

   panel(constraints: BorderLayout.SOUTH) {
            button text: 'Save', actionPerformed: {


    Component[] components = allx2.getComponents();
println  components
    for (int i = 0; i < components.length; i++) {

        if(components[i].getClass().getName().toString().equals("javax.swing.JTextField")){
            components[i].setEnabled(false);
println    components[i]
        }
    }



            }
        }



       } 
    }

我用这个解决

import groovy.swing.SwingBuilder 
import groovy.beans.Bindable 
import static javax.swing.JFrame.EXIT_ON_CLOSE 
import java.awt.*
import groovy.transform.Field


    def swingBuilder = new SwingBuilder()
    swingBuilder.edt {  
        frame(title: 'Address',   id:"allx" ,size: [350, 230],
                show: true, locationRelativeTo: null,
                defaultCloseOperation: EXIT_ON_CLOSE) {
            borderLayout(vgap: 5)

            panel(constraints: BorderLayout.CENTER,   id:"allx2" ,
                    border: compoundBorder([emptyBorder(10), titledBorder('Enter your address:')])) {
                tableLayout( id:"allxgg") {
    tr{  

      td {       textField  id:"date",text="01-01-18", columns: 10     } 

    }

    tr{  

      td {       textField  id:"dat3e",text="01-01-18", columns: 10     } 

    }


  tr{ 

      td {       textField  id:"dateg",text="01-01-18", columns: 10     } 

    }

    tr{  

      td {       textField  id:"dat3eg",text="01-01-18", columns: 10     } 

    }

    }

     }

   panel(constraints: BorderLayout.SOUTH) {
            button text: 'Save', actionPerformed: {


    Component[] components = allxgg.getComponents();
println components.size()
println  components[3].getText()





            }
        }



       } 
    }