Eu queria fazer com que ao clicar sobre um ícone fosse possível abrir uma tela, executar um ação qualquer e etc.
Eu queria colocar formatos diferentes, por isso não uso um JButton
. Pois ao passar a imagem para ele, ele continuou "retangular". Mais, no caso de existir algum componente que possa assumir a forma de uma imagem ou mesmo fazer com o JButton, também é válido.
Exemplo clicar sobre um pequeno circulo:
package pacote01;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class NovoClass extends JFrame
{
private JPanel painel = new JPanel();
public NovoClass()
{
setSize(200, 150);
ImageIcon image = new ImageIcon(getClass().getResource("/imagens/icone.png"));
JLabel imagelabel = new JLabel(image);
painel.add(imagelabel);
add(painel);
setVisible(true);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args) {
NovoClass novo = new NovoClass();
}
}