• 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

Background color doesn't change using setBackground()

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should call:

 
Raman Ghai
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic