Hello :-)
I have a map of JLabels displaying in a JPanel, within a JScrollPane.
When the cursor enters a hex, the corresponding JLabel icon repaints itself as a red hexagon. When the cursor exits, it repaints itself as a black hexagon.
I used absolute positioning on the JPanel and added the JLabels using add()
Each JLabel is 21x21 and the hexagon is 20x20. This allows the hexes to overlap by a pixel to the right and below/right. Without this, the JLabels didnt display the hexagons properly - each JLabel set to 20x20 resulted in the row end hexes losing the right and below/right edges of the hexagon.
The first hex displays correctly but the rest do not. I think this is because of the order the JLabels are added to the JPanel combined with the overlapping (by 1 pixel) of the JLabels.
Somehow, I need to change the display order of the JLabels so that the one that has detected the cursor entering it gets re-ordered to the top of the list of JLabels displayed on the JPanel. Then it can repaint itself and should show up correctly.
I experimented with JLayeredPane but the map load time was too long (there are 10,000 map hexes) whereas using JPanel, the load time is acceptable.
Any helpful ideas?
Thanks
Darren
[ November 30, 2004: Message edited by: D R Wilkinson ]
[ November 30, 2004: Message edited by: D R Wilkinson ]
[ November 30, 2004: Message edited by: D R Wilkinson ]
[ November 30, 2004: Message edited by: D R Wilkinson ]