Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Working in Eclipse but not from the command line  RSS feed

 
Dakota Benningfield
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey!

I have recently started learning Java and I'll be honest I'm having a pretty difficult time.
That aside I was following a tutorial to create a basic game engine just so i could gain some basic understanding.
Now I followed the tutorial and what i created works in Eclipse for the intended purpose. What it's supposed to do is create a screen and then create a black box that can be moved up, down, left, right via the keys W,A,S,D.
Now when I run it from the command line it creates a screen(JFrame) but the black box doesn't ever show up. I'm just trying to understand why not as it works as intended when run from eclipse, I'm using the same class files in both, I originally did it in notepad then copied and pasted in eclipse just
to give it one last try (as it was not working from the command line). Any help or explanation would be very appreciated.

Edit: I after trying it a bunch Ive found it does work, but not all the time? Now i am even more confused













 
Knute Snortum
Sheriff
Posts: 3549
85
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This will probably do better in the Swing forum, moving.
 
Knute Snortum
Sheriff
Posts: 3549
85
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is "KeyboardListener" and "MousepadListener"?
 
Dakota Benningfield
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are objects to accept input from the Mouse and the Keyboard. And after testing it a ton of times I'd say it works about 90% of the time from the command line, and 100% in eclipse.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I notice you're calling repaint() from the paint() method in your JPanel subclass, and that's a Swing faux pas. The repaint() method says "Hey, you probably need to call the paint() method pretty soon" which isn't the case when you're inside paint(). Calling it from elsewhere is fine, and it's what you should do when you want the JPanel to be redrawn.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!