Android Open Source - eent-for-android Button Listener






From Project

Back to project page eent-for-android.

License

The source code is released under:

GNU General Public License

If you think the Android project eent-for-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * ButtonListener.java/*w  w  w . j  a va 2  s .c om*/
 *
 * Created on March 9, 2003, 2:37 PM
 */
/*
 It is distributed under the GNU Public Licence (GPL) version 2.  See
 http://www.gnu.org/ for further details of the GPL.
 */
package eu.veldsoft.eent;

/**
 *
 * @author  ali
 */
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;

class ButtonListener implements ActionListener {
  JButton sel;
  Grid selected;

  /** remember the previous selected button */
  public static Grid lastSelected;

  String gridText;

  public void actionPerformed(ActionEvent e) {
    if (Board.currentPlayer == null) {
      return;
    }
    if (Board.currentPlayer.isCPU() == true) {
      return;
    }

    sel = (JButton) e.getSource();
    gridText = sel.getActionCommand();
    Board.pressed = gridText;
    if ((gridText == Tigris2.OK)) {
      // TODO
    } else if (gridText == Tigris2.CANCEL) {
      // TODO
    } else {
      selected = (Grid) sel;
      if (lastSelected != null) {
        lastSelected.setTile(selected);

        if ((lastSelected.getActionCommand()).endsWith("B")) {
          lastSelected.setBorder(null);
        } else {
          lastSelected.setBorder(BorderFactory.createEtchedBorder());
        }
      }
    }
    selected.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2,
        Color.green));
    lastSelected = selected;
  }
}




Java Source Code List

eu.veldsoft.eent.BagListener.java
eu.veldsoft.eent.Bag.java
eu.veldsoft.eent.Board.java
eu.veldsoft.eent.ButtonListener2.java
eu.veldsoft.eent.ButtonListener.java
eu.veldsoft.eent.CatTile.java
eu.veldsoft.eent.CheckBoxListener.java
eu.veldsoft.eent.CivTile.java
eu.veldsoft.eent.ComputerPlayer.java
eu.veldsoft.eent.Grid.java
eu.veldsoft.eent.HumanPlayer.java
eu.veldsoft.eent.Kingdom.java
eu.veldsoft.eent.LeadTile.java
eu.veldsoft.eent.Player.java
eu.veldsoft.eent.ScoreCounter.java
eu.veldsoft.eent.TemTile.java
eu.veldsoft.eent.Tigris2.java
eu.veldsoft.eent.Tile.java
eu.veldsoft.eent.Util.java