programing question

programing question

how do i use loops(for,while) to add components in java

View Answers

November 15, 2010 at 11:48 AM

Hi Friend,

The below code might help you.

import java.awt.*;
import javax.swing.*;

class TextFieldArray extends JFrame{
 JLabel  l[]=new JLabel [5];
 JTextField  t[]=new JTextField [5];
public TextFieldArray(){
JPanel panel=new JPanel(new GridLayout(5,2));
for(int i=0;i<5;i++){
    int j=i+1;
l[i]=new JLabel("Label"+j);
t[i]=new JTextField(5);
panel.add(l[i]);
panel.add(t[i]);
}
add(panel);
setVisible(true);
pack();
}
public static void main(String[] args){
new TextFieldArray();
}
}

Thanks









Related Tutorials/Questions & Answers:
programing question
programing question  how do i use loops(for,while) to add components in java   Hi Friend, The below code might help you.ADS_TO_REPLACE_1 import java.awt.*; import javax.swing.*; class TextFieldArray extends JFrame
Java programing
Java programing   need help wrting this Write a program that has an array of 5 Strings, and determines which ones are palindromes (letter-case does not matter). thanks
Advertisements
socket programing in servlet
socket programing in servlet  give me a example to write socket programing in servlet
question
question  Sir, Please give me a source code for client server socket programing in java
programing
programing
programing
programing
programing
programing
programing
programing
programing
programing
Programing Help - Java Beginners
Programing Help  how to design a filebrowser in java "witout using Swing
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
Question
Question   When there is an exception in my program how java runtime system handles
question
question  dear sir/madam my question is how to compare two text format in java..we are java beginners..so we need the complete source code for above mentioned question...we have to compare each and every word
question
question  Dear sir i had some typing mistake at previous question so its my humble request to let me know the steps to start the tomcat6 under the tomcat directory
SOCKET PROGRAMING IN THE JAVA FOR NETWORKING CONCEPT
SOCKET PROGRAMING IN THE JAVA FOR NETWORKING CONCEPT  I WANT TO KNOW ABOUT THE JAVA SOCKET PROGRAMING FROM BASIC LEVEL AND HOW CAN I WORK ON IT I KNOW THE JAVA PROGRAMING.SO PLEASE HELP ME HOW CAN I DO SOCKET PROGRAMING
cnc programing course
cnc programing course  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: cnc programing... the topic "cnc programing course". Also tell me which is the good
Java programing help
Java programing help  Can you help me create this program? Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed). As they enter the data, assign
question
question  Gud morning sir, I have asked u some question regarding jsp in saturaday for that i didnot find any answere in which u send me the some of the links.U have asked me the specify some details. There is a entity name
Question?
Question?  My question is how to: Add a menu bar to the program with a File menu. In the File menu, add a submenu (JMenuItem) called About. When the user clicks on the About menu item, display a JOptionPane message dialog
javascript programing error - JSP-Servlet
javascript programing error  hi deepak i m using explorer to run javascript program in this there is no option to check error will u plz tell me the way to check error in explorer as we can check with mozila
help with substring in c programing
help with substring in c programing  Hi I could not found programming in C in the "select category" so I am posting my question in java section. Please help with substring function,prompt the user for two strings and display
java programing problem - Java Beginners
java programing problem  Create a class named Movie that can be used with your video rental business. The Movie class should track the Motion picture Association of America rating , ID Number, and movie title with appropriate
cnc programing classes near me
cnc programing classes near me  Hi, I am beginner in Data Science... programing classes near me Try to provide me good examples or tutorials links so that I can learn the topic "cnc programing classes near me". Also tell
guys,, need help,, in java programing,, arrays
guys,, need help,, in java programing,, arrays  create a program where you will input 10 numbers and arrange it in ascending way using arrays
java programing
programing - IoC
programing - WebSevices
java programing
Javascirpt Programing
C++ programing
c programing
c programing
java programing
java programing
Java Programing
socket programing
Question on pooling
Question on pooling  which server supports pooling?Application server or web server
This question in Jmeter
This question in Jmeter  hi..i want to send request(xml) 100 times but each time in request xml one element needs to change, otherwise request will be failed since its duplicate
Question on javascript
Question on javascript  This is not exactly what i wanted....If i enter in 2nd combobox as name of child then it should show child id in 1st combobox automatically and vice versa
C# question
Create a Solution by name Bank with Classes Account.cs, SavingsAccount.cs and savingsTest.cs to Demonstrate Abstract Classes in C#  1st question : Create a Solution by name Bank with Classes Account.cs, SavingsAccount.cs
question for c++
question for c++   write Program to swap between two numbers if first number is greater than second number and total of two numbers greater than 10
Inheritance question?
Inheritance question?  Q3)Create a class hierarchy as Company extended by AccountsDepartment. AccountsDepartment extended by AccountsReceivable... as AccountsPayable. please send the code of this question soon....plzzzzzzzz  
Inheritance question?
Inheritance question?  Q3)Create a class hierarchy as Company extended by AccountsDepartment. AccountsDepartment extended by AccountsReceivable... as AccountsPayable. please send the code of this question soon....plzzzzzzzz View
Question in Eclipse
Question in Eclipse   ** Hello EveryOne , L Have Question in Eclipse ?!! Question is : A.( The square class) Design a class named Square that contains : 1.A private instance variable side of type double 2.A no-argument

Ads