 <p>You should just consider using JButton but to answer the question:</p> <hr> <p><br>Try using MouseListener with BevelBorder for example:</p> <pre><code>yourPanel.addMouseListener(new MouseListener() { Border b = new BevelBorder(BevelBorder.LOWERED); Border originalBorder = null; @Override public void mouseReleased(MouseEvent e) { ((JComponent)e.getComponent()).setBorder(originalBorder); } @Override public void mousePressed(MouseEvent e) { originalBorder = ((JComponent)e.getComponent()).getBorder(); ((JComponent)e.getComponent()).setBorder(b); } ... }); </code></pre> <h1>Examples:</h1> <h2>Not clicked:</h2> <p><img src="https://i.stack.imgur.com/GM2Gw.png" alt="Not clicked"></p> <p><br></p> <h2>Clicked:</h2> <p><img src="https://i.stack.imgur.com/PA9WF.png" alt="Clicked"></p>