*
The moose likes Swing / AWT / SWT and the fly likes Making a good looking grid in Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Making a good looking grid in Swing" Watch "Making a good looking grid in Swing" New topic
Author

Making a good looking grid in Swing

Matthieu Saenen
Greenhorn

Joined: Mar 07, 2013
Posts: 1
Hello everyone, at the end of next week I need a Battleship game, but I'm stuck with making a 2d grid. I have to make something like the photo, but i don't even know how to begin on it. In the grid it are all nice squares and they are all nice ligned out, How did they do that?

http://www.imagebam.com/image/687e73241745809


[ScreenShot001.jpg]

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37902
    
  22
Welcome to the Ranch

Fix the sizes of all those squares. Try a grid layout. There are lots of layouts, which you can find about in the Java Tutorials.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37902
    
  22
Use gradient painting for that colour shading. Draw multiple lines at right angles to each other. (This suggestion is instead of the layout and many squares, not in addition.)
Cameron Miller
Greenhorn

Joined: Jan 10, 2013
Posts: 13

Draw the background, then use two for loops to draw the grid, one for the vertical lines and one for the horizontal lines. E.g.


This would create a 10x10 grid starting at (10, 10).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making a good looking grid in Swing
 
Similar Threads
SCWCD - Passed with 91%
How to save jquery-grid to MySql database table?
editable grid in extjs?
how i use java applet data grid i have many record i need show in grid
Grid in Jasper report