Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

PLAF: sideeffect resizing and painting

Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to give another shape (a polygon other than a square) to a JButton by creating another ButtonUI. I am however encountering some problems
1. The fillPolygon(myPolygon) from Graphics does not seem to work when i am trying to paint the new shape. However a drawPolygon(myPolygon) and a fillOval(0, 0, width, height) do work.
2. When the frame containing the JButton is resized, there are traces of the outline of the button (from a call to drawPolygon()) for all the sizes that the button is while the frame is being resized.
Would anyone have an idea of what i could be doing wrong or missing. Thanks in advance.
Here is the code i am using in case it might be helpful:

regards Vik
[ January 16, 2003: Message edited by: vik nuckchady ]
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've run your code, and I don't see either of the problems you mention... fillPolygon() works for me, and I don't see the redraw problem... I'm using JDK 1.4.1, what version are you using? One thing that I would recommend is that you put the outline Polygon inside the paint method... otherwise you keep adding points to the polygon, which may cause the redraw problem you see...

Here's the code that I am using... ( I also modified the code to make a triangular button instead of rectangular... )

Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic