Results 1 to 2 of 2
Thread: Help with pictures en Java
- 07-13-2007, 09:56 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 44
- Rep Power
- 0
Help with pictures en Java
Recently, I found that initialzing a new ImageIcon in the paint function is a terrible thing to do, as it will always look for the image which will slow the game down and/or flicker.
So the solution to this problem is to define the ImageIcon in the class, and call the picture in public void init or something.
However, would I have to do this process for 100++ pictures? I tried to use and array to load all my pictures, but then I had a problem finding the one I needed. Is there another solution to stop the game from being so slow/flickering?
Or just a better way to do this in general?
- 08-07-2007, 04:36 AM #2
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
Can you associate the pictures with some type of string?
Such as the filename or something of that sort?
That way you can look it up in a hashmap which will give you as close as O(1) time as you're going to get.
There is also included a way to get the entrySet from the hashmap if you need to go through each of them.
This is included in the API:
HashMap
Basically I think you need to look into ways to optimizing the whole thing. It may be worth wild to do a search on Google about optimizing java code. Besides that without looking at the code I can't tell you much else about it.
Greetings.
Similar Threads
-
The Funny Pictures Thread(this means a lot of pictures...)
By joshua in forum EntertainmentReplies: 22Last Post: 07-25-2012, 09:51 PM -
Help Loading Up Pictures
By marco in forum Java AppletsReplies: 3Last Post: 08-14-2007, 10:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks