Bonjour à tous !

Voila j'ai crée une classe qui implémente MouseListener.

Le but etant de detecter un clic de souris dans une zone de mon image et d'afficher une nouvelle fenetre (un tableau par exemple) en conséquence.

Je met ma classe en entier afin de comprendre le probleme.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
 
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
 
 
class IHMImages extends JPanel implements MouseListener  {
 
 
	private static final long serialVersionUID = 1L;
	private static final Rectangle    ZONE_IMAGE_401 = new Rectangle(113, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_404 = new Rectangle(179, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_406 = new Rectangle(245, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_409 = new Rectangle(311, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_411 = new Rectangle(377, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_413 = new Rectangle(443, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_415 = new Rectangle(509, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_432 = new Rectangle(575, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_433 = new Rectangle(641, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_434 = new Rectangle(707, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_435 = new Rectangle(773, 127, 47, 35);
    private static final Rectangle    ZONE_IMAGE_436 = new Rectangle(853, 127, 47, 35);
 
	Image train, bouton_vert, bouton_jaune,bouton_rouge;
 
	public BufferedImage image    =  null;
 
 
 
	public void Image1(BufferedImage train) {
        this.addMouseListener(this);
        this.train = train;
    }
 
 
	IHMImages() {
		try {
			train = ImageIO.read(new File("train_123456.JPG"));
			bouton_vert = ImageIO.read(new File("bouton-vert.gif"));
			bouton_rouge = ImageIO.read(new File("bouton-rouge.gif"));
			bouton_jaune = ImageIO.read(new File("bouton-jaune.gif"));
		}
		catch(IOException exc) {
			exc.printStackTrace();
		}
		setPreferredSize(new Dimension(1018, 370));
		setBackground(Color.WHITE);
	}
 
 
 
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
 
 
		g.drawImage(train, 0, 0, this);
		g.drawImage(bouton_vert, 100, 50, this);
		g.drawImage(bouton_vert, 230, 50,this);
		g.drawImage(bouton_vert, 300, 50,this);
		g.drawImage(bouton_jaune, 450, 50,this);
		g.drawImage(bouton_rouge, 520, 50,this);
		g.drawImage(bouton_vert, 670, 50,this);
		g.drawImage(bouton_vert, 745, 50,this);
		g.drawImage(bouton_jaune, 60, 70,this);
		g.drawImage(bouton_vert, 925, 70,this);
 
 
		g.setColor(Color.red);
		g.drawRect(ZONE_IMAGE_406.x, ZONE_IMAGE_406.y, ZONE_IMAGE_406.width, ZONE_IMAGE_406.height);
 
		// getWidth()     getHeight()
	}
 
 
 
 
 
 
 
	 public void testLocation(Point mouse, Rectangle area, String text) throws SQLException {
         // test si la souris est dans les data de l'image
 
 
     	String pilote = "com.mysql.jdbc.Driver";
	        Connection connexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/mabase","root",""); 
	        Statement instruction = connexion.createStatement();
 
	        try {
	        	//int effacement_donnee = instruction.executeUpdate("DELETE FROM table_temporaire_code_defaut");
	        	ResultSet train_401 = instruction.executeQuery("SELECT * FROM table_temporaire_code_defaut WHERE Caisse LIKE '%26501%' OR '%26502%' OR '%262501%' OR '%262502%' ORDER BY SUBSTRING(Date_heure, 7, 2), SUBSTRING(Date_heure, 4, 2), SUBSTRING(Date_heure, 1, 2),SUBSTRING(Date_heure, 10, 2),SUBSTRING(Date_heure, 13, 2),SUBSTRING(Date_heure, 16, 2),SUBSTRING(Date_heure, 19, 2)"); 
 
 
	        }
	        	catch (Exception e)
           	 {
          	   e.printStackTrace();
             }
 
 
	        	if(ZONE_IMAGE_406.contains(mouse))
	        	{
	        		System.out.println(" £££££££££££££ CAISSE TTT : £££££££££££" );
	        		//new JFrame().setVisible(true);
	        	}  
 
 
         }
 
 
 
 
	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		 Point p = e.getPoint();
         try {
				testLocation(p, ZONE_IMAGE_406, "mouseClicked - data 1");
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
 
	}
 
	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
 
 
	}
 
	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
 
	}
 
	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		Point p = e.getPoint();
 
	}
 
	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		Point p = e.getPoint();
 
	}
 
}


Code : Sélectionner tout - Visualiser dans une fenêtre à part
private static final Rectangle    ZONE_IMAGE_401 = new Rectangle(113, 127, 47, 35);
Permet de dessiner un petit rectangle pour connaitre les zones ou la detection de clic est effective.

J'ai fait plusieurs tentative sans succes.
Mon image est composés de plusieurs images supperposé, j'ai pensé que ça venait de la mais j'ai bien l'impression que non.

En fait, lorsque je compile mon programme , eclipse ne rentre pas dans ma fonction
Code : Sélectionner tout - Visualiser dans une fenêtre à part
public void testLocation(Point mouse, Rectangle area, String text) throws SQLException {
J'ai essayé de débugger en mettant des affichages consoles mais je ne voit pas comment faire pour rentrer dans cette fonction.

Merci pour votre aide