GridBagLayout and JTextField

Discussion in 'Java' started by me, Jul 16, 2003.

  1. me

    me Guest

    I'm attempting to place a textfield, using GridBagLayout. The syntax
    I'm using is

    addComp(jtf, gbLayout, gbConstraints, 0, 0, 1, 4, 0, 0);

    with 'jtf' being the textfield. Its my understanding that this should
    create the textfield, in row 0, column 0, with a height of 1 row, and
    a width of 4 columns. When run, this creates a textfield that is in
    the center of row 0, but is of a massively compressed size.(The two
    end lines and a sliver of white) Strangely, when the same syntax is
    used to place a JLabel in the same place, it works fine, with the
    label spanning the whole width that it should. I've attempted to
    change the size of the JTextField when its created, but to no avail,
    even when its set to a wider width than exists in the frame. Any
    suggestions on why this is, or how to get around this issue??

    Sorry if this double posted, the news server I'm on seems screwy
    tonight.

    Mark
     
    me, Jul 16, 2003
    #1
    1. Advertising

  2. me

    Ike Guest

    you need to give it a starting size (in chars, of the default Font I
    believe), e.g.
    myJTextField = new JTextField(6);
    I believe,. from your description, you are just creating a new
    JTextField();

    //-Ike

    "me" <smpatfield@REMOVETHIS_sympatico.ca> wrote in message
    news:...
    > I'm attempting to place a textfield, using GridBagLayout. The syntax
    > I'm using is
    >
    > addComp(jtf, gbLayout, gbConstraints, 0, 0, 1, 4, 0, 0);
    >
    > with 'jtf' being the textfield. Its my understanding that this should
    > create the textfield, in row 0, column 0, with a height of 1 row, and
    > a width of 4 columns. When run, this creates a textfield that is in
    > the center of row 0, but is of a massively compressed size.(The two
    > end lines and a sliver of white) Strangely, when the same syntax is
    > used to place a JLabel in the same place, it works fine, with the
    > label spanning the whole width that it should. I've attempted to
    > change the size of the JTextField when its created, but to no avail,
    > even when its set to a wider width than exists in the frame. Any
    > suggestions on why this is, or how to get around this issue??
    >
    > Sorry if this double posted, the news server I'm on seems screwy
    > tonight.
    >
    > Mark
    >
     
    Ike, Jul 16, 2003
    #2
    1. Advertising

  3. me

    Sudsy Guest

    me wrote:
    > I'm attempting to place a textfield, using GridBagLayout. The syntax
    > I'm using is
    >
    > addComp(jtf, gbLayout, gbConstraints, 0, 0, 1, 4, 0, 0);
    >
    > with 'jtf' being the textfield. Its my understanding that this should
    > create the textfield, in row 0, column 0, with a height of 1 row, and
    > a width of 4 columns.


    Without the source for addComp, we wouldn't know what it's supposed
    to do. I don't even see where you add the component to the container.
    While I applaud your effort to reduce the problem to the essentials,
    we're missing a few of those essentials.
     
    Sudsy, Jul 21, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ulf Meinhardt
    Replies:
    13
    Views:
    1,336
    steve
    Apr 16, 2006
  2. nukleus
    Replies:
    8
    Views:
    554
    nukleus
    Feb 10, 2007
  3. nukleus

    GridBagLayout and its pitfals

    nukleus, Feb 8, 2007, in forum: Java
    Replies:
    2
    Views:
    505
    nukleus
    Feb 9, 2007
  4. nukleus

    GridBagLayout and its pitfals

    nukleus, Feb 9, 2007, in forum: Java
    Replies:
    0
    Views:
    405
    nukleus
    Feb 9, 2007
  5. Daniel Pitts
    Replies:
    0
    Views:
    333
    Daniel Pitts
    Mar 25, 2007
Loading...

Share This Page