001 package ch.uzh.ifi.attempto.echocomp; 002 003 import nextapp.echo.app.Button; 004 import nextapp.echo.app.event.ActionListener; 005 006 /** 007 * This class represents a small square button with one of the following predefined icons: right, 008 * down, plus, diamond. 009 * 010 * @author Tobias Kuhn 011 */ 012 public class SquareButton extends Button { 013 014 private static final long serialVersionUID = -3555338733759467195L; 015 016 private static final String imgpath = "ch/uzh/ifi/attempto/echocomp/style/"; 017 018 /** 019 * Creates a new square button. 020 * 021 * @param iconName The name of the icon button. 022 * @param tooltip The tooltip to be shown. 023 * @param actionListener The action listener. 024 */ 025 public SquareButton(String iconName, String tooltip, ActionListener actionListener) { 026 setRolloverEnabled(true); 027 setRolloverBackground(Style.lightBackground); 028 if (tooltip != null) { 029 setToolTipText(tooltip); 030 } 031 addActionListener(actionListener); 032 setIconName(iconName); 033 } 034 035 /** 036 * Creates a new square button. 037 * 038 * @param iconName The name of the icon button. 039 * @param actionListener The action listener. 040 */ 041 public SquareButton(String iconName, ActionListener actionListener) { 042 this(iconName, null, actionListener); 043 } 044 045 /** 046 * Changes the icon name. 047 * 048 * @param iconName The new icon name. 049 */ 050 public void setIconName(String iconName) { 051 setIcon(Style.getImage(imgpath + iconName + ".png")); 052 } 053 054 }