Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8408441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:37:57+00:00 2026-06-09T23:37:57+00:00

I am creating an GUI application in java that uses input from the user

  • 0

I am creating an GUI application in java that uses input from the user and dynamically sets up textfield in my jFrame with default names like jTextField1,jTextField2 etc

My projects demo is as follows:-

enter image description here

1) It accepts number of rows and columns from combo box.

2)It should set the number of columns and rows as per the selection of
user. (ie it should dynamically create Jtextfield objects on the
JFrame)

Can i dynamically setup these commands inside a looping statement and create the number of textfields i need :-

     private void initComponents() {
    jTextField1 = new javax.swing.JTextField();
            jTextField2 = new javax.swing.JTextField();
}


private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;

Or is there any other methods to do the same.

Is this Possible in any other languages like javascript or html.

Any help is appreciated !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:37:59+00:00Added an answer on June 9, 2026 at 11:37 pm

    Your approach is right. You loop through the indexes and create the new components (Java GUI objects) and add them to the container.

    Remember to either check existing components or remove()/removeAll() them.

    UPDATE:
    When you create a Container you usually define a LayoutManager (I am more familiar with GridBagLayout, but XYLayout could be useful for you). When adding a component to a Container, you have a method that allows an extra object constraints; that object is passed to the layoutManager to know where / how to draw the component added.

    Of course, each different layoutManager uses its own different constraints, so for the GridBagLayout I pass a GridBagConstraints object. In your example, to build a row, all the fields except the ones would be added by a default GridBagConstraints; the GridBagConstraints in the last row would have

     GridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    

    to notify the layout manager that it is the last item in the row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a GUI application that requires the user to provide lots of numeric
I'm creating a gui application that requires some simple input, however, when I click
i am creating a java application which is will be GUI for a bash
I'm creating a GUI application that can monitor and manipulate a stream of messages.
I am creating a Java Application using netBeans and Swing Gui Builder. I am
I am creating a java Sudoku GUI application at the moment. The grid for
I am creating a GUI application(wxPython). I need to run another (.exe) application from
I'm creating a Java application in NetBeans, and I have the following code that
Possible Duplicate: Creating online help in Java Swing application - using pdf user docs
I'm creating an application that need a nice GUI and some openGL rendering (I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.