Listing 5 registers an ActionListener object
You have seen code like this in numerous previous lectures.
Therefore, a detailed explanation of Listing 5 should not be required here.
Listing 5. Register a listener object on the button. |
---|
setColorButton.addActionListener( new ActionListener(){ public void actionPerformed(ActionEvent e){ //Set the color to green. redInt = 0; greenInt = 255; blueInt = 0; //Show the color values in the text fields. redField.setText("" + redInt); greenField.setText("" + greenInt); blueField.setText("" + blueInt); }//end action performed }//end new ActionListener );//end addActionListener |
File: at.htm | [Next] | [Prev] |