Results 1 to 5 of 5
  1. #1
    martypapa is offline Member
    Join Date
    Feb 2010
    Posts
    21
    Rep Power
    0

    Default Any reason why half of components aren't drawing?

    Hi
    I've got a container that is meant to be drawing up to 100 JComponents.
    Only about half of them are being drawn to the screen.
    They are definitely being added to the container, as I have run several tests.
    It seems that only the last 10 or so components that were added are being drawn.

    Is there some sort of limitation on the number of components that can be drawn by a container?

    Thanks

  2. #2
    martypapa is offline Member
    Join Date
    Feb 2010
    Posts
    21
    Rep Power
    0

    Default

    I just realised that I had forgotten to call validate. I thought that this would surely solve the problem, but no luck. This has had me stumped for the past two day, any advice would be great!
    Some more information:
    Each run of the game always gives a different number of components being drawn.
    I tried running the game and skipping the menu screen, and it appeared to show more components, so perhaps this is a memory issue?
    One thing is always the same - the components always start from the last in the array, so that the first element of the array is almost never shown.

  3. #3
    martypapa is offline Member
    Join Date
    Feb 2010
    Posts
    21
    Rep Power
    0

    Default

    It is now working!
    I think the problem lay in sending an Image as an argument to a class. I think I'll just stay away from that from now on.

  4. #4
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    It is better to load an image only once, if you can help it; once it's loaded you can pass it to a great many objects as arguments.
    My Hobby Project: LegacyClone

  5. #5
    martypapa is offline Member
    Join Date
    Feb 2010
    Posts
    21
    Rep Power
    0

    Default

    I think that the problem was that I was trying to pass an unloaded image to an object, and that object used the image to get its dimensions. So I figure, it was being given a width and height of 0. So what I did was feed the desired width and height to the object, and then created a variable and set it to the image, which worked perfectly.

Similar Threads

  1. loop in a half
    By Brain_Child in forum New To Java
    Replies: 4
    Last Post: 12-02-2009, 04:00 AM
  2. [SOLVED] Can't pinpoint reason for this error..
    By Reiyn in forum New To Java
    Replies: 6
    Last Post: 03-30-2009, 07:39 PM
  3. Getting errors for some reason
    By Swarvy in forum New To Java
    Replies: 7
    Last Post: 09-30-2008, 03:45 PM
  4. Telecommute only at half rate
    By Johnny Kewl in forum Jobs Wanted
    Replies: 0
    Last Post: 05-11-2008, 05:05 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
  •