java - Moving Component in GridLayout -


i have 30x30 gridlayout of jpanels. each cell in 30x30 frame jpanel image. aka tiles on map.

i need move character (red jpanel) around map on keypress.

how can this? not see way of replacing component in gridlayout :s

also, there better way replacing component because if replace it, i'd have keep track of old component when character moves next tile, replaces old component character used be.

gridlayout not solution problem. reason: gridlayout sort components in order write "container.add(component)" statements. can't put component @ specific place, other inserting dummy components places before.

you might want try gridbaglayout.. in gridbaglayout, you've on key event update location of dynamic panel , shall displayed on top of fixed panel @ location.. no need remember old component


Comments