• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

drawing

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic