Adding a ActionPerformed Array to a String Array
- by user267490
Hey,
Before you guys ask, yes I've searched online for the answer, but everything I found just leaves a lil confuse and nothing is recent so asking in those forums won't really help.
My problems is this:
I have an array that holds my name for a menu.
String[] fontColor = new String[] {"Red", "Blue", "Green"};
for (int i = 0; i < fontColors.length; i++) {
JMenuItem fontC = new JMenuItem(fontColors[i]);
fontC.addActionListener(new fontColorAction());
changeFontColor.add(fontC);
}
Then I have an array that holds my color change in a class called fontColorAction
in that class I have another array that does the same thing as my string array except all thats in the statement is textarea.setForeground(colorArr[i]);
that will set the setForeground() in order, but now how do I successfully attact the action listner in my class to my menuItems?
my class looks like this
private class fontColorAction implements ActionListener {
Color[] colorArr - new Color[] {"Color.RED","Color.BLUE","Color.GREEN"};
public void actionPerformed(ActionEvent e){
for(i = 0; i < collorArr.length; i++){
textarea.setForeground(colorArr[i]);
}
}
}