Java Code for grid display