• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI Color Changer

 
Vern Vernetta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34656
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic