Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Java GUI Elements now drawing


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 nitishk   Members   -  Reputation: 161

Like
0Likes
Like

Posted 31 March 2013 - 12:34 PM

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



Sponsor:

#2 swiftcoder   Senior Moderators   -  Reputation: 10409

Like
2Likes
Like

Posted 01 April 2013 - 08:02 PM

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 - Software Engineer @Amazon - [swiftcoding]


#3 LorenzoGatti   Crossbones+   -  Reputation: 2779

Like
0Likes
Like

Posted 02 April 2013 - 03:57 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).
Produci, consuma, crepa




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS