Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange graphpics behaviour...

Status
Not open for further replies.

Casbah

Programmer
May 18, 2004
31
IE
I have written a program to demonstrate my solution to the UnisexBathroom concurrency program.
My GUI has 5 areas, a counter which works fine and counts down the number of males and females waiting to use the bathroom.
An input area for the user to enter how many males and females will initially join the q. This also works fine.
A play and exot button, both working fine...

Now the unusual behaviour...
My GUI contains 2 large pictures, which get set to male/female and NOmale/NOfemale, depending on who's allowed into the bathroom at a certain time. The correct picture is always being displayed, however in the background random pieces of the GUI appear, disappear and reappear, they go away at the end, but it looks terrible while the program is running.
I also have 5 cubicle icons which change to men or women depending on who currently occupies them. The same behaviour is occuring here.

If anyone has many ideas why this is happening or a solution Id be most grateful. Ive heard people talk about image loading but I dont really know anything about this, should I preload all the images at the start? At the moment, they get loaded as they are needed. I dont know if this is the problem though as the correct images are appearing, its the random junk behind them Im worried about.

Thanks, Conor
 
How are you running the program? From command line or from any kind of IDE?

Remember that if your program is consuming CPU, the Swing thread could be busy and needs some time to refresh.

Anyway, with ladies in the bathroom, I'd assume that random things will happen :)

Cheers.

Dian
 
Im running from the command line and from an executable jar file with the same results. i wrote the GUI by hand which could be my problem. but it does seem like it needs time to refresh.
 
My advice would be to import the java.aws.* class.
And use the mediatracker class this will not allow a pic be displayed untill it is fully loaded, this is done by using the WaitforId() method
hope this helps

PDB123
 
Sorry the AWT class not the AWS, AWT (Abstract windowing toolkit)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top