public class SelectionArea extends JComponent { private Rectangle currentRect = null; private Rectangle rectToDraw = null; private Rectangle previousRectDrawn = new Rectangle(); private boolean move = false; private RecadrageApplet controller; private int imageW; private int imageH; private ImageIcon imageCopy = null; private int xdiff; private int ydiff; PhotoSelection photoOrg = null; private PhotoSelection ps; public SelectionArea(ImageIcon image, RecadrageApplet controller) { // super(); imageW = image.getIconWidth(); imageH = image.getIconHeight(); this.controller = controller; this.ps = controller.getPhotoSelection(); //controller.information.setJTextMaxTailleEcran(controller.persist.getPhotoSelection().getGoHMax() + "x" + controller.persist.getPhotoSelection().getGoVMax()); float xHRmm = Calcul.calculPixel2Mm((int) (ps.getLargTotalHR() * ps.rapportTailleX())); float yHRmm = Calcul.calculPixel2Mm((int) (ps.getHautTotalHR() * ps.rapportTailleY())); controller.getJLabelTaillePhotoValeur().setText(Calcul.arrondir( xHRmm, 2) + " x " + Calcul.arrondir(yHRmm, 2)); imageCopy = image; this.controller = controller; // setOpaque(true); setMinimumSize(new Dimension(10, 10)); //don't hog space controller.setSize(imageW + 200, imageH + 100); MyListener myListener = new MyListener(); addMouseListener(myListener); addMouseMotionListener(myListener); } /** * This method initializes this * * @return void */ private void initialize() { } protected void paintComponent(Graphics g) { /* variable de classe contennant l'image à afficher en fond */ // super.paintComponent(g); //pose l'image /* Surcharge de la fonction paintComponent() pour afficher notre image */ //g.drawImage(imageCopy.getImage(), 0, 0, null); g.setColor(Color.BLACK); g.fillRect(0, 0, 200, 200); System.out.println("Paint"); /* //Si currentRect existe on fait dessine le rectangle par dessus if (currentRect != null) { if (move != false) { g.setXORMode(Color.WHITE); g.fillRect(0, 0, imageW, imageH); g.setXORMode(Color.WHITE); g.fillRect(rectToDraw.x, rectToDraw.y, rectToDraw.width - 1, rectToDraw.height - 1); } else { g.drawRect(rectToDraw.x, rectToDraw.y, rectToDraw.width - 1, rectToDraw.height - 1); } } */ } ....