• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

animation of a flashing orange lights

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


How can i make it remain permanently on orange when the steady button is clicked?
 
Saloon Keeper
Posts: 3291
146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Ion,

to get permanent orange light when the state is steady, I made some small adjustments. There are other ways, of course, but here goes:

1) I dropped the variable 'changeColors'.

2) I introduced, at Belish level, the field 'private Color currentColor = Color.ORANGE;'

3) in the timer, I changed the code to:

4) likewise, I simplified the paintComponent-method to:

5) and for the two buttons, I changed the code to:

And now you have a steady orange light when clicked on 'steady'.

 
Marshal
Posts: 64639
225
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BelishN? Surely that should be Belisha, after Leslie Hore-Belisha, who was the British Minister of Transport during whose period of office the flashing orange light at pedestrian crossings was introduced.
 
Piet Souris
Saloon Keeper
Posts: 3291
146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Who???      
 
Campbell Ritchie
Marshal
Posts: 64639
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:Who???

Him.
 
Campbell Ritchie
Marshal
Posts: 64639
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:Who???

See Wikipedia link in my earlier post.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!