Results 1 to 6 of 6
  1. #1
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default [SOLVED] Prevent JTextField from Expanding Within JFrame

    Hi there.

    I have a JLabel, a JTextField, and numerous other components in a JFrame. As the JFrame expands vertically, the JTextfield also expands vertically. I am wondering if there is any way to prevent this, since I can't seem to figure it out. Any help is greatly appreciated.

    Thanks in advance,
    Singing Boyo

    P.S. If you want code, I can give it to you. It's just long and confusing. It also has another file you'd need, but I could send that along. Hopefully this is a simple thing to fix.
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    826
    Rep Power
    6

    Default

    Hi,
    I think u can goahead with GridBagLayout and set the constraints.

    -Regards
    ramya
    Ramya:cool:

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    It all depends upon what layout managers are used where. To get a detailed answer, I think that you are going to have to post code, and we'd ask that you do your best to simplify it so that it shows only the needed components to demonstrate your problem and nothing more, called a Short, Self Contained, Correct (Compilable), Example.

  4. #4
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    Nevermind this... I got numerous other errors within the code. I'm just going to rebuild from scratch and hopefully not end up with the same problem.
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Seems to me too, this is all about the layout you are using. If you can it's better to post some of your code to see. May be it's easy to you, rather coding from the begging.

  6. #6
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    Solved it. Layout was SpringLayout, and it treats objects as expandable if getPreferredSize() != getMaximumSize(). Just had to decide how big I wanted it and set the sizes accordingly.
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

Similar Threads

  1. Collapsing/Expanding() All nodes in a TreeMenu using javascript
    By Hadley in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 01-30-2009, 11:18 PM
  2. Replies: 1
    Last Post: 01-30-2009, 06:44 PM
  3. Prevent escape from closing a SWT dialog
    By Java Tip in forum SWT
    Replies: 0
    Last Post: 07-02-2008, 07:58 PM
  4. Replies: 2
    Last Post: 04-09-2008, 11:14 AM
  5. Replies: 0
    Last Post: 01-21-2008, 01:29 PM

Posting Permissions

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