Hello!
I try to do a image in a frame to advance a few pixels to click the image
The problem comes to add the image in a label and I try to call the label in a method addMouseListener() and after Mouseclicked()
The code in which I do it itīs it:
/************* This is the part af code where I have the request *//////////////////////////////////// Ejemplo.getContentPane().add(etiqueta, BorderLayout.CENTER); /* 109 */ etiqueta.addMouseListener(new MouseAdapter() /* */ { /* */ public void mouseClicked(MouseEvent paramMouseEvent) /* */ { /* 113 */ System.out.println("pepe"); /* 114 */ Ejemplo.this.sw2 = 1; /* */ } /* */ }); /************* This is the part af code where I have the request *////////////////////////////////////
etiqueta is a label and adds the label is the image.
This code is in the constructor, in Ejemplo(){}.
in the main class of the java program, in "public class Ejemplo extends JPanel
/* */ implements KeyListener, Runnable
/* */ {"
I put the code of the label, it is:
static ImageIcon imagen1 = new ImageIcon("rectangulovacio.jpg"); static JLabel etiqueta = new JLabel(imagen1);
and the program work, I created the file "Ejemplo.class" but not work the method "MouseClicked" because I click in the image and not happen anything... I can't do the program so? Thanks