sure! I originally just had the actionPerformed get the text from the textField, but that didnt seem to work, so i put in a Button to actually tell it to fetch the text...but yeah, ive been fiddling around an i've got this far...but the new problem is, it doesnt work! do you have any ideas?
Code:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class FlowerMain3 extends Applet implements ActionListener {
double x, y;
float alphaValue = 0.40f;
TextField textColour;
Button change;
Color colourFallback = Color.BLACK; // or whatever you want instead.
Color colourUsed = colourFallback;
public void init(){
textColour = new TextField(10);
change = new Button("Change Colour");
change.setActionCommand("change");
add(textColour);
add(change);
textColour.addActionListener(this);
change.addActionListener(this);
}
public void paint(Graphics g) {
int n = 10;
double angle = 360 / n;
int radius = 100;
for (int i = 0; i < n; i++) {
x = Math.cos(Math.toRadians(angle * i)) * radius;
y = Math.sin(Math.toRadians(angle * i)) * radius;
Graphics2D alpha = (Graphics2D) g;
g.setColor(colourUsed);
alpha.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaValue));
alpha.fillOval((int) x + radius+40, (int) y + radius+50, 2 * radius, 2 * radius);
}
for (int i = 0; i < n; i++) {
x = Math.cos(Math.toRadians(angle * i)) * radius;
y = Math.sin(Math.toRadians(angle * i)) * radius;
g.setColor(Color.black);
g.drawOval((int) x + radius+40, (int) y + radius+50, 2 * radius,2 * radius);
}
}
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("change")){
Color c = Color.getColor(textColour.getText());
if (c != null)
colourUsed = c;
else
colourUsed = colourFallback;
}
}
}
Thanks for looking at it! 
-Crawf
Bookmarks