Sign in to follow this  
chosenkill6

Finding logic error

Recommended Posts

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 :/

Share this post


Link to post
Share on other sites

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?).

Edited by unbird

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this