Hi, I need to create a simple grid component that provides the following capabilities: 1) Can be constructed with an arbitrary number of rows and columns. 2) Each cell is capable of triggering an event in response to user input in that cell. 3) The entire grid should be able to be overlaid with an image. As an approach, I'm thinking of extending the AWT panel class and creating individual panels for the cells formed by the rows and columns. If anyone has done something similar before and can offer comment on this that would be helpful. Kind regards, Adam
hi, why won't you use JTable (ok, or Table) for this - extending it if necessary. JTable.setBackground() should be able to accept an image (maybe not, try JScrollPane as well). the cells can be edited and the event part shouldn't be a problem. chantal
I would extend the AWT Panel, Canvas, or just Component classes... does the grid need to appear on top of the image, or does the image just have to have seperate clickable areas? Add a MouseListener to this component, and use the getX() getY() methods of the MouseEvent passed to it to determine where in the grid was clicked... I know that a Rectangle class is in AWT, maybe those can also be used as grid cells...
I'll post some code to illustrate this soon...
Write once, run anywhere, because there's nowhere to hide! - /. A.C.