File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes GUI Color Changer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GUI Color Changer" Watch "GUI Color Changer" New topic

GUI Color Changer

Vern Vernetta

Joined: May 01, 2010
Posts: 2
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

Joined: May 26, 2003
Posts: 33106

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
pete stein

Joined: Feb 23, 2007
Posts: 1561
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!
I agree. Here's the link:
subject: GUI Color Changer
It's not a secret anymore!