• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Gui for Conway's Game of Life

 
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how about creating a grid of rectangles using Graphics2D class ?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Graphics2D is for painting with. It doesn't create rectangles or any other Shape.
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Marshal
Posts: 25924
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I'm still in control here. LOOK at this tiny ad!
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic