• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Working in Eclipse but not from the command line

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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













 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This will probably do better in the Swing forum, moving.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is "KeyboardListener" and "MousepadListener"?
 
Dakota Benningfield
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic