problem with Jframe netbeans POO events

3

I am working with events in Java Swing and it happens that in a JFrame I have uploads of three images. What I need is to know how I do so that when I press an image when I run the program it moves vertically and I can stop it with another click or by clicking on the second image. If I click on the second image, the first image must be stopped and the other image must be moved. How can I get this result in Netbeans?

    
asked by paola 10.04.2017 в 20:56
source

1 answer

0

If you wrap the images in a JLabel , you can add a

// sea img tu imagen (por ejemplo BufferedImage)
JLabel label = new JLabel(img);

label.addMouseListener(new MouseAdapter() {
  @Override
  public void mouseClicked(MouseEvent e) {
     ... procesar el evento ...
  }
});

in the part where you process the event you can add an animator that moves you the components where you want to have them.

    
answered by 10.04.2017 / 21:40
source