• 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

GUI Color Changer

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the program is supposed to change the fill color of a predetermined shape from slider or text field values. The problem is that my sliders aren't updating from text field values. I've seen several examples of how to specify the event using KeyListner on the web, but my teacher specified that we should be using ActionListner.

I'd appreciate any help.



I apologize for the miscellaneous code. I tend to jump from problem to problem when I get stuck.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vern,
Welcome to JavaRanch!

Did you know we have a forum just for Swing/AWT type questions? I'll move this for you. The link will take you to the new location.
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're never changing the colors of the displayed P6PaintPanel.

A few suggestions.
1) The P6PaintPanel added to the JApplet's contentPane has to be visible in the class so that you can change its state (its Color) when desired. This means that you shouldn't create an anonymous object in the add(...) method but rather use the class P6PaintPanel field and don't forget to initialize it.

2) I'd give the P6PaintPanel a public method that allows outside classes to set the Color (or if desired, the redValue, greenValue, and blueValue ints).

3) I'd call this method on the displayed P6PaintPanel object whenever the color changes, and then call repaint() on the JPanel (or you could have repaint() be part of the setColor(...) method.

Much luck!
 
reply
    Bookmark Topic Watch Topic
  • New Topic