import java.awt.Button; import java.awt.Graphics; /** This class represents a button on the construction panel.*/ public class CP_Button extends CP_Item { /** A reference to the connected button. */ private MyButton button; /** A reference to a connection object that will be created when a connection is added to this object. */ private CP_Connection conn = null; /** The constructor. */ public CP_Button(MyButton _button) { type = 1; button = _button; w = 60; h = 30; } /** Returns the x-position of the connection port. _port is not used here but we need it for compatibilty. */ public int getPortX(int _port) { return x+w/2+3; } /** Returns the y-position of the connection port. _port is not used here but we need it for compatibilty. */ public int getPortY(int _port) { return y; } /** Returns the reference to the connected button. */ public MyButton getButton() { return button; } /** Sets the connection to another object. _port is not used here but we need it for compatibilty. */ public void setConnection(int _port, CP_Connection _conn) { conn = _conn; } /** Gets the connection to another object. _port is not used here but we need it for compatibilty. */ public CP_Connection getConnection(int _port) { return conn; } /** Draws the object. */ public void draw(Graphics g) { g.drawRect(x-w/2, y-h/2, w, h); g.drawArc(x+w/2,y-3,6,6,0,360); g.drawString("Button:",x-w/2+5,y); g.drawString(name,x-w/2+5,y+10); } }