This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Gui for Conway's Game of Life 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 "Gui for Conway Watch "Gui for Conway New topic
Author

Gui for Conway's Game of Life

naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

hi ranchers,

Need suggestion for developing the Gui interface of Conway Game of Life. I think Swing does not have components to display a grid of cells.

Please suggest a library or api to create a gui.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
If you really want to use Swing components, then a GridLayout (with each cell holding some custom component of yours) might work, although that would be a very unusual approach.

You could use a JTable with very small cells.

I'd probably use a Canvas with each cell represented by a cluster of 2x2 or 3x3 pixels.


Ping & DNS - my free Android networking tools app
naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

how about creating a grid of rectangles using Graphics2D class ?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Graphics2D is for painting with. It doesn't create rectangles or any other Shape.


luck, db
There are no new questions, but there may be new answers.
naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

public void paint(Graphics g) {

g.drawRect (100, 50, width, height);

}

Graphic class has drawRect() to draw rectangle, will it not work f i create grid of these rectangle ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Bear in mind that the size of the configurations you'll encounter can be unbounded. In other words you could require a very large area to draw on. You might want to provide scrolling, rather than trying to scale extremely large displays into a component of fixed size.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Gui for Conway's Game of Life
 
Similar Threads
sample application or mini project regarding threads
beautiful moments of life...
Where to store the game state.
XML and aspect-oriented programming
WA #1.....word association