Original Post
I'm making a simple editor for tile based maps, and I'm using a JTabbedPane with canvas classes in each tab to represent the different layers of my map (eg the bottom layer of tiles only shows if there is nothing on the layers above it etc). What I want to do is add appropriate mouselisteners to the tabbedpane so that I can paint tiles onto the canvases using the mouse. However, mouselisteners added to the JTabbedPane class only seem to work on the selection tabs, and not the things actually in the tabs (my canvases). So from what I can see I have two options. The first is to make a seperate mouse listener for each canvas and bind them to the actual canvases. Would this have a big performance hit (I'm looking at about 4 tabs)? The second is to have one mouselistener and add a ChangeListener to the tabbedpane which removes the mouse listener from the tab which is no longer visible, and then adds it to the one which has become visible. This all seems very messy, is there a better way of doing it? And if not which of these methods is the 'cleanest' and best for performance? Thanks