I am making a 2d platformer and am producing the map maker. So far, I have my java project splitting an image of tiles into 100 seperate images, and putting them in buttons (tile[]). When one of these buttons is clicked, it fires the MouseListener:
public void mousePressed(MouseEvent e) {
for(int i = 0; i <= 99; i++) {
tile[i].setBackground(null);
}
((JComponent) e.getSource()).setBackground(Color.black);
}
Now, I need to know if there is a JComponent that can make this easy for me, I want to be able to click in a canvas or something, and start drawing the map (24x24 pixel grids). How would I go about doing this? If you need more code or me to explain better please ask.
Use a JToggleButton
as shown in Swing JToolbarButton pressing.
Obviously this will require 2 images for each map 'tile' location. The first is the map tile for that part of the map, the second is a black image that can be reused for every tile.