Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I dont understand, why it wont work?  RSS feed

 
Andreas Slirig
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have got this code, but it wont work for me .

it is suppose to spawn random ovals and rectangels in random places in an windows white random colors. please help me!

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does 'it doesn't work' mean? Please TellTheDetails (<= link).
 
Andreas Slirig
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i start the program that is suppose to show a JPanel with spawning random items on it, i add it to a JFrame but all i get is a gray screen and nothing happens in it.

cant even push the exit button in the right corner, i have added EXIT_ON_CLOSE so it should work

 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andreas Slirig wrote:When i start the program that is suppose to show a JPanel with spawning random items on it, i add it to a JFrame but all i get is a gray screen and nothing happens in it.

Well I'm no GUI expert, but I'm surprised you're not getting any message about ambiguous references, because java.util also has a Random class.

Winston
 
Andreas Slirig
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okey i take away the java.util ?

but still i'm left whit a grey window and nothings shows in it
 
Andreas Slirig
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks any way did a different version and now it works great !
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andreas Slirig wrote:Thanks any way did a different version and now it works great !

Congratulations! For the sake of other beginners, why don't you post the code that worked?

Winston
 
Andreas Slirig
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sure here it is

 
Manuel Petermann
Ranch Hand
Posts: 177
Hibernate Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Would be better as you should only call swing methods from the event dispatch thread.
You might get weird behaviour if you don't do this.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!