I need little Help with my Java project.
I have about 60 buttons which should each run another application located in computer. I know how to set mouseClicked event to do this:
public void mouseClicked(MouseEvent e) {
try {
Process p = Runtime.getRuntime().exec("address");
} catch (IOException ex) {
Logger.getLogger(CustomAct1.class.getName()).log(Level.SEVERE, null, ex);
}
}
but I don't know how to set different address to each button without creating seperated class for every single button. I now use this:
CustomAct open = new CustomAct();
but1.addMouseListener(open);
but I need to do it also for "but2", "but3" and so on.
Thank in advance.
addMouseListener