This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello 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:
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... )
Write once, run anywhere, because there's nowhere to hide! - /. A.C.