Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Background color doesn't change using setBackground()

 
Raman Ghai
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am following some tutorials for making games:
Here are my classes:
Screen.java

Main.java


I get the text on the screen but the background color is black ...
I have no idea about this. Any suggestions ?
 
Nam Ha Minh
Ranch Hand
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should call:

 
Raman Ghai
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nam Ha Minh wrote:You should call:


When I use the above code, I get an error saying "nonstatic method cant be accessed from a static context."
So, I simply used but still nothing .
I get a BLACK background with blue text written on it .

If I change the color quality to 32 bit in the DisplayMode() constructor , the background doesn't appear .
It simply writes the text on the desktop.

 
Nam Ha Minh
Ranch Hand
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have tried to compile and run your program. I see the red background, but after a while an exception is thrown:

 
Raman Ghai
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
This means that the display mode is not supported by the videocard. Well , I will run the code on my desktop as well . And try different display modes
such as


By the way , the screen size of my laptop is 1366 x 768 , color quality = 32 bit , refreshrate = 60 .
This is strange that my laptop didn't give any exception about the invalid display mode. I used command line to compile and run the programs . which IDE did you(Mr Nam Ha Minh) use ?
I think it should not make any difference but we never know .
thanks for replying
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic