getactioncode

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Daniel
    New Member
    • Feb 2011
    • 4

    getactioncode

    This is my last chance, I am VERY new at this, I am trying to complete a checkerboard array, The code that I have compiles and runs, however I have to put in a getactionsource or something like that to make the clear button clear the field and the colors in the checkerboard back to white. I have attached the code that I have. I am thinking that I have to enter something like

    Code:
    boolean condtion = true;  
    
    while(condition)
    maybe a try or if statement
    then

    Code:
    getactionsource ("clear");  
    
    boardDisplay[i].setbackGround(Color.white);
    but I am not clear, and I have been trying everything for over a week now and can't get it to work.
    please help
    Thanks
    Attached Files
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Get the action command on button click and figure out which button is fixed and perform appropriate actions.

    Code:
    if(e.getActionCommand().equals("Clear")){
    	for (int i=0; i<boardDisplay.length; i++){
    		boardDisplay[i].setBackground(Color.magenta);
    	}
    	return;
    }
    Regards
    Dheeraj Joshi

    Comment

    Working...