Finding logic error

Started by
1 comment, last by BCullis 11 years, 1 month ago

I have spent about 2 hours now trying to find this one logic error in my code. The problem is, I have 5 JLabels and in each there is an ImageIcon. Sometimes a JLabel will draw, sometimes it won't. I am using eclipse. Is there any good ways to debug logic errors using either some debug tools in eclipse or some programming technique that will help me find the error. Getting really frustrated at myself right now :/

Advertisement

Interactive applications like GUIs are hard to debug with an integrated debugger: a simple breakpoint disturbs a GUIs control flow and can trigger events which without debugger wouldn't occur. I don't know about eclipse, but what I did when I programmed GUIs was dumping relevant info right in the GUI (label, textbox): Internal states, event trigger counts etc.

If all fails, there's always log-files. The latter has the advantage that you can detect race conditions (what did occur after what?).

I have spent about 2 hours now trying to find this one logic error in my code. The problem is, I have 5 JLabels and in each there is an ImageIcon. Sometimes a JLabel will draw, sometimes it won't. I am using eclipse. Is there any good ways to debug logic errors using either some debug tools in eclipse or some programming technique that will help me find the error. Getting really frustrated at myself right now :/


Can you post the code that sets up the JLabels?
Do you change the value of the JLabels and/or their ImageIcon data after initialization?

I recommend using System.out.println debug statements if you're using Eclipse (just to surround suspected problems and check values). The console is right there in the IDE, it might get spam-y due to the redraw loops of the GUI, but it could highlight your problem.

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)

This topic is closed to new replies.

Advertisement