• Post Reply Bookmark Topic Watch Topic
  • New Topic

drawing  RSS feed

 
kalai sundar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem is ,
Let explain with example
In a chess boad many blocks r there,right! vat i want is, if the user choose certain blocks, those block should be filled with colures, and i want to place some data to the colour filled blocks.
How should i do?
Do i have to go for Jtable, or java graphics or any other third party tool,
Can u plz give me some solution?


with regards
kalai
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two general approaches to this:
1 — component approach. You can make a GridLayout and add JLabels that can be used to show color (they must be 'setOpaque' to do this) and information.
2 — graphics approach. Here you do all the rendering in the 'paintComponent' method (assuming you are using Swing components like JPanel). Draw a grid and you can set colors in rectangles. The 'drawString' part takes a little more work but it's mostly a matter of counting and using Font class methods for precise positioning.

The first option may be easier and the second allows more control. Either way you will need to keep track of things in the class that manages the colors/messages for selected cells.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!