/* * StringListCanvas.java * * Created on December 13, 2005, 2:33 PM */ package Current.gui; import java.awt.*; import java.awt.event.*; import org.pat.graphics.boxed.ListenString; /** * * @author pat */ public abstract class StringListCanvas extends Canvas implements MouseListener, MouseMotionListener { public String[] S; public ListenString[] LS; static final int padding=4; public int selected=-1; // translation to scroll by int ty, pressed_y; Color bg, box, highlight, text; /** Creates a new instance of StringListCanvas */ public StringListCanvas() { setFont(new Font("sanserif", Font.PLAIN, 12)); } /** This should be called first to setup colors*/ public void setColors(Color bg, Color box, Color highlight, Color text){ setBackground(bg); this.bg=bg; this.box=box; this.highlight=highlight; this.text=text; } /** then this */ public void setNames(String[] S) { LS=new ListenString[S.length]; double x=padding, y=padding; for (int i=0; i0) { if (ty<-(LS[LS.length-1].getBottom()+ padding-getHeight())) ty=-(int)(LS[LS.length-1].getBottom()+ padding-getHeight()); } if (ty>0) ty=0; for (int i=0; i