Like K. Tsang correctly pointed out check out the API docs for GridLayout. It even has a working example.
In case you run int trouble, post your SSCCE code here so we can help point you in the right direction.
Yashwanth Raj wrote:sorry .it is grid layout.and not grouplayout.but when i use 'grid layout' the buttons are well arranged of order 3x3.but when i add a menu bar,it also becomes like a cube rather than like a bar on the top next to the title bar.i tried both grid and group layouts.but group layout is too complex.so is there any other layouts to arrange the buttons of order 3x3 without affecting the menubar?
Are you setting the layout for the entire frame as GridLayout or just a Panel when the buttons go.
By default the JFrame default layout is BorderLayout.
Yashwanth Raj wrote:... i also want the menu bar on top for menus like game start and game exit
Recommended reading http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html