File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes PLAF: sideeffect resizing and painting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "PLAF: sideeffect resizing and painting " Watch "PLAF: sideeffect resizing and painting " New topic

PLAF: sideeffect resizing and painting

vik nuckchady

Joined: Apr 25, 2001
Posts: 25
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 ]
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

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.
I agree. Here's the link:
subject: PLAF: sideeffect resizing and painting
It's not a secret anymore!