Sunday, 15 February 2015

java - Loop the JButton in three color when clicked? -


How do I change the loop to make the piston color green, yellow, white when it is clicked? If I want to click it yellow then click again again, then click, then turns green, and so on.

  Public Zero Mousechat (Mouse Event E) {countClick ++; Switch (countClick) {Case 0: m.btn.get (m.btn.indexOf (e.getSource ()) SetBackground (Color.yellow); breakdown; Case 1: m.btn.get (m.btn.indexOf (E.getSource ()) setBackground (Color.yellow); breakdown; Case 2: mbtnjet (mbtn.indexoff (eds.SSSS) ). Setbackground (ColorAid); CountClick = 0;}} If the button is already yellow, I have to click it twice. Note: The buttons are stored in the array list And I used the loop to add it to the grid layout. This is how I used to add jabyutan to gridlate, it is in another category.  
  BTN = new ArrayLite <> (); while ((text = br.readline ()) = = Null {tmp = text.split (","); for (int i = 0; i  

You can try it

  Private c countClicks = 0; Public Zero Functionality (Action EVE) {countClicks ++; Switches (countClicks) {Case 0: boutton.setBackground (Color.YELLOW); break; Case 1: Botton. Setbackground (color. WHITE); break; Case 2: Botan. Setbackground (color green); CountClicks = 0; break; }  

No comments:

Post a Comment