Results 1 to 4 of 4
  1. #1
    miller.bartek is offline Member
    Join Date
    Jan 2011
    Posts
    8
    Rep Power
    0

    Default TextField problem.

    Hi everyone,
    what I wanted to achieve was a resizeable JTextField of width equal to a frame width. Successfully I did it, but I have some doubts about the another solution which unfortunately doesn't work.

    I attached a print screen showing my code in two different versions and results.
    I would be grateful for explanation.

    Thanks in advance.
    Bart

    API says:
    JPanel() - Creates a new JPanel with a double buffer and a flow layout.
    JPanel(LayoutManager layout) - Create a new buffered JPanel with the specified layout manager

    edit: My question is: Why in the first example the goal is achieved and in the second one a JTextField is squeezed in the middle?
    Attached Thumbnails Attached Thumbnails TextField problem.-panel-layout.jpg  
    Last edited by miller.bartek; 01-10-2011 at 06:46 PM.

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

  3. #3
    hosscomp is offline Member
    Join Date
    Oct 2010
    Posts
    63
    Rep Power
    0

    Default

    edit: My question is: Why in the first example the goal is achieved and in the second one a JTextField is squeezed in the middle?
    In the first example you use a Border Layout and in the second you use a Flow Layout.
    Look up Layout Managers and how they work. They can be hard to understand without
    experimenting.

  4. #4
    miller.bartek is offline Member
    Join Date
    Jan 2011
    Posts
    8
    Rep Power
    0

    Default

    Thank you for your help.
    I read a little bit about Layouts and it seems to be clear.

Similar Threads

  1. Won't set to textfield
    By Steffers in forum New To Java
    Replies: 7
    Last Post: 11-04-2010, 03:32 PM
  2. 1 question regarding textfield
    By henry in forum New To Java
    Replies: 3
    Last Post: 06-16-2010, 04:56 AM
  3. Textfield border problem
    By jurka in forum AWT / Swing
    Replies: 2
    Last Post: 08-31-2008, 10:15 AM
  4. TextField Example
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-25-2008, 03:21 PM
  5. JSP - getting value from a textfield
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-01-2007, 09:58 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
  •