Explain this code in simple terms

0 Shaheedul Islam · August 24, 2015
Can you explain this code for me 
.

String[] labels = {"Name: ", "Fax: ", "Email: ", "Address: "};
int numPairs = labels.length;

//Create and populate the panel.
JPanel p = new JPanel(new SpringLayout());
for (int i = 0; i < numPairs; i++) {
   JLabel l = new JLabel(labels[i], JLabel.TRAILING);
   p.add(l);
   JTextField textField = new JTextField(10);
   l.setLabelFor(textField);
   p.add(textField);
}

//Lay out the panel.
SpringUtilities.makeCompactGrid(p,
                               numPairs, 2, //rows, cols
                               6, 6,        //initX, initY
                               6, 6);       //xPad, yPad

Post a Reply

Replies

Oldest  Newest  Rating
0 Shaheedul Islam · August 25, 2015
Thank you
  • 1

Java / Android Development

106,962 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator