Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Want to pass randomly chosen color to setBackground(Color.xyz)

 
Ranch Hand
Posts: 100
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the issue is wrong argument type, string v. static.
What is the right way to do this?




1 error found:
File: /home/whoami/javaClass/EventDemo.java [line: 280]
Error: /home/whoami/javaClass/EventDemo.java:280: cannot find symbol
symbol : variable backgroundColor
location: class java.awt.Color

I also tried



And erred:

File: /home/whoami/javaClass/EventDemo.java [line: 281]
Error: /home/whoami/javaClass/EventDemo.java:281: cannot find symbol
symbol : method setBackground(java.lang.String)
location: class EventDemo.DisplayPanel

Both errors are on the last line of the code

 
Ranch Hand
Posts: 802
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of using a String [], use a Color []. That way you can get a random integer and get the Color object at that index and use it.
Color doesn't have a static variable/function called 'backgroundColor', that's why you're getting that error.

Justin
 
Igor Mechnikov
Ranch Hand
Posts: 100
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Justin Fox wrote:Instead of using a String [], use a Color []. That way you can get a random integer and get the Color object at that index and use it.
Color doesn't have a static variable/function called 'backgroundColor', that's why you're getting that error.

Justin[/quote

Great advice. Thank you.

 
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic