0

Im trying to get all component name when click a button in groovy panel

but my command not get all component ; how i could correct this code in

groovy

I dont know how get all

Please help me with this problem ;

Im using getcomponent() command but not get all component of my panel

i need get compoentn date and 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]
        }
    }



            }
        }



       } 
    }
mightguy
  • 175
  • 1
  • 8
  • 1) Use a logical and consistent form of indenting code lines and blocks. The indentation is intended to make the flow of the code easier to follow! 2) See [What is the XY problem?](http://meta.stackexchange.com/q/66377) – Andrew Thompson Mar 02 '18 at 15:36

1 Answers1

0

I solve with this

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()





            }
        }



       } 
    }
mightguy
  • 175
  • 1
  • 8