Results 1 to 2 of 2
  1. #1
    gawkes1 is offline Member
    Join Date
    May 2011
    Rep Power

    Default Creating and positioning components in loop

    Hi I've got following code
    Java Code:
        JFrame PassengerData = new JFrame("Dane pasażerów");
        PassengerData.setSize(new Dimension(350,400));
        JTextField[] PassengerName=new JTextField[5];
        for(int i=0;i<5;i++)
            PassengerName[i]=new JTextField(""+i);
            PassengerName[i].setLocation(10, 10+(i*30));
    Every textfield except last one is placed where I wanted to, the last one stetches to the size of JFrame and I've got no idea how to fix it
    Last edited by gawkes1; 05-31-2011 at 12:57 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    What layout manager are you using? Are you giving the correct constraint in the add()?

Similar Threads

  1. Need Help Creating A Loop!
    By chrisnojen117 in forum New To Java
    Replies: 3
    Last Post: 05-12-2011, 08:30 PM
  2. Creating a loop help !
    By theman279 in forum New To Java
    Replies: 5
    Last Post: 03-10-2011, 11:13 AM
  3. Creating a Loop
    By SenorJalapeno in forum New To Java
    Replies: 3
    Last Post: 04-02-2010, 11:13 AM
  4. tutorials 4 creating windows components
    By jaytee in forum New To Java
    Replies: 1
    Last Post: 03-07-2010, 09:48 PM
  5. creating New Components in swings
    By sandeepsai17 in forum New To Java
    Replies: 11
    Last Post: 07-13-2009, 07:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts