Results 1 to 5 of 5

Thread: Fixed location

  1. #1
    Dipke is offline Member
    Join Date
    Aug 2010
    Location
    Leuven, Belgium
    Posts
    86
    Rep Power
    0

    Question Fixed location

    Hello,

    i can set the location of a "textArea" to ex : 100,100 using setLocation(100,100).

    But when i change the size of the frame the position is changed also.

    Is there a way of fixing the position or must the position be set in "paintComponent" ?

    Kind regards

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default

    The location must *never* be set in any painting method override. Painting methods are for painting and only painting, don't ever alter the state of the component there.

    Learn to use layout managers.
    Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    db

  3. #3
    Prajin's Avatar
    Prajin is offline Senior Member
    Join Date
    Jun 2010
    Location
    Ktm, Nepal
    Posts
    120
    Rep Power
    0

    Default

    When you add any componets in Frame, it's layout is managed by certain layouts.
    So when size of frame changes, it affects all components - size, positions etc.
    Using layout is very good. Notice when you resize any window frame, how all it's components try to manage in best possible manner. That's cool isn't it.

    But if you really want static postition, don't use layouts, set it to null for frame.

    - Regards

  4. #4
    Dipke is offline Member
    Join Date
    Aug 2010
    Location
    Leuven, Belgium
    Posts
    86
    Rep Power
    0

    Default

    Hello,

    thanks for the reply.
    What do you mean by setting it to null for frame ?

    kind regards

  5. #5
    Dipke is offline Member
    Join Date
    Aug 2010
    Location
    Leuven, Belgium
    Posts
    86
    Rep Power
    0

Similar Threads

  1. Fixed Header
    By Quirl in forum New To Java
    Replies: 2
    Last Post: 07-28-2010, 10:19 PM
  2. need to copy file from one location to another location
    By naveen.dpt2007 in forum New To Java
    Replies: 4
    Last Post: 02-28-2010, 03:53 PM
  3. location provider returns no location
    By sandeeprao.techno in forum CLDC and MIDP
    Replies: 0
    Last Post: 09-24-2009, 09:54 AM

Tags for this Thread

Posting Permissions

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