• 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

Hi i'm trying to do a diamond. i don't know whats wrong with my program. so can anyone help

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i'm currently trying to do a diamond using Polygon.
i have done this so far.
can anyone tell me whats wrong. it is not drawing a diamond.
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't use the paint method. Override paintComponent (with protected access).
 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like this ?

 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is your SSCCE? You asked for an example SSCCE in your first question and your were given one.

Why does you code not look like the painting code found in the Swing tutorial on "Custom Painting". In your first two questions you were given a link to the tutorial.

Why are you not following the advice given in the past? If you want help in the future, make sure you follow advice given in the past. We don't have time to keep repeating ourselves.
 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
should the code look like this?
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly.

Now why are you using negative values? Negative values will be painted outside the view of the panel.

Start with something simple, like a square. It should be easy to define the four points of a square.

Once you get that working change the 3rd set of points to stretch one vertex. Then try changing other points. The hard part is not the GUI code. The hard part is specifying your points correctly.

In other words start with something simple and then make changes one at a time to see what happens so you understand what is happening.

Also, this SSCCE can now be used as a basis for all future questions. The main() and createAndShowGUI() parts will be the same. All that will change in the future is the panel. In most cases you will add components to the panel to demonstrate a problem.

A SSCCE is a great tool for simplifying your problem.
 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Rob Camrick. i will try to start with a square first
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on 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