import java.awt.*; public class RectButton { int m_iXPos, m_iYPos; int m_iWidth, m_iHeight; int m_iBorderWidth=1; Color m_cMain = Color.white, m_cBorder = Color.black; public RectButton (int iXPos, int iYPos, int iWidth, int iHeight) { m_iXPos = iXPos; m_iYPos = iYPos; m_iWidth = iWidth; m_iHeight = iHeight; } //-------------------------------------- // Call this from mouse functions public boolean bMouseOver (int x, int y) { if (x < m_iXPos) return false; if (x > m_iXPos + m_iWidth) return false; if (y < m_iYPos) return false; if (y > m_iYPos + m_iHeight) return false; return true; } //-------------------------------------- // This needs to be called from your paint function. public void paint (Graphics g, Color cMain, Color cBorder) { if (cMain != null) m_cMain = cMain; if (cBorder != null) m_cBorder = cBorder; g.setColor(m_cMain); int iX = m_iXPos + m_iBorderWidth, iY = m_iYPos + m_iBorderWidth; g.fillRect(iX, iY, m_iWidth - 2*m_iBorderWidth, m_iHeight - 2*m_iBorderWidth); g.setColor(m_cBorder); for (int C=0; C