Hello, How toadd an eventto an object (class)and capture it? I createdthree objects(man- Ball -rectangle)and I would likein themainprogram whenI clickwiththemouse on anobjectSoftware Processingtold mewhereI clicked. (get me the name of object) thank you
// mes classes Bonhome monBonh; Boule maBoul; Rectangle monRect;
void setup() { size(300,300); noLoop(); monBonh = new Bonhome("Homme.gif"); maBoul = new Boule(25, 50,30,30,125); monRect = new Rectangle(50,100,40,40,150); }
void keyPressed() { lines = new String[0]; String filename = "arabe1.txt"; File f = new File(dataPath(filename));
if(f.exists()) { //lines = loadStrings(filename);
try { /* Open a stream to a File (in your data Folder) here */ InputStream fi = createInput(filename); /* get a reader with your encoding */ InputStreamReader input = new InputStreamReader( fi, Charset.forName("UTF-8") ); BufferedReader reader = new BufferedReader(input);
// read the file line by line String line; int counter = 0; while ((line = reader.readLine()) != null) { lines = append(lines, line); counter++; } reader.close(); } catch (IOException e) { e.printStackTrace(); } }
for ( int i = 0 ; i < lines.length;i++) println(lines[i]); }