Java GUI Elements now drawing

Started by
1 comment, last by LorenzoGatti 11 years ago

First of all, I apologize for posting so much code, I really have been at this for hours now and I am beyond frustrated, I cannot seem to find the error in my code. I never post all my code on here for help but really I am at a loss as to what else I can do. This is pretty much my last ditch effort to find it, I really don't know what to do after this. There is not much to the code, it is just very repetitive. Any help would really be greatly appreciated. If anyone could even just point me in the right direction I would really be grateful.

Here is my project file for eclipse:

https://www.dropbox.com/s/8j21k4f6kojt9t0/Yahtzee%202.0.zip

If you would like to just look at the code online:

YahtzeeMain.java : http://pastebin.com/U29ggrxd

GUIThread.java: http://pastebin.com/Hbg5AShJ

GUIFrame.java: http://pastebin.com/dxHsY8nB

Player.java: http://pastebin.com/ByK8043V

Advertisement

You probably need to invoke your (oddly named) GUIThread via SwingUtilities.invokeLater().

In general, you can't perform GUI setup on the main thread, as it needs to occur on the event dispatch thread.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

If you know enough about Swing to understand the basic mechanism, i.e. enough to design a GUI application without major guesswork, debugging should be unusually straightforward and effective for this kind of issue.

You have a known target, the paint() or paintComponent() methods of your classes, and a simple breakpoint at their beginning is going to cover all likely bug categories: find out if and when your drawing code is actually called, inspect variables which could be different from your expectations (for example the position of other GUI elements that might hide the problem ones), and follow the actual drawing that takes place (in case it's wrong).

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement