aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "PLAF: sideeffect resizing and painting " Watch "PLAF: sideeffect resizing and painting " New topic
Author

PLAF: sideeffect resizing and painting

vik nuckchady
Greenhorn

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

regards Vik
[ January 16, 2003: Message edited by: vik nuckchady ]
Nathan Pruett
Bartender

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... )



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PLAF: sideeffect resizing and painting
 
Similar Threads
Can someone please fix my code?
Good User Interface
Round Button Border
custom shaped gui components?
a Jbutton with a rounded border