You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to piccolo...@googlegroups.com
Hi, I have been attempting (unsuccessfully so far) to create a PCanvas with a GradienPaint background and then place my components onto the canvas. Could any one please tell me how to do this? setBackground() only accepts a Color and I can't find a way to pass a Paint (GradientPaint) object into the canvas creation/settings.
Thanks for any help.
Patrick.
Michael Heuer
unread,
Jul 31, 2014, 5:32:26 PM7/31/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to piccolo...@googlegroups.com
Hello Patrick,
PCanvas is a Swing JComponent, so any method for painting a gradient
on the background of a JComponent should work, e.g.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to piccolo...@googlegroups.com
Hi Michael, Thanks for the quick reply. I did in fact try the exact method you recommended in the link; however overriding the paintComponent method fo the PCanvas as shown in the link does not produce a Gradient paint background. It seems as though the super.paintComponent() call still makes the background solid. Do you have any experience with this or have you ever had to implement a gradient paint canvas background?
Thanks.
Patrick.
Michael Heuer
unread,
Jul 31, 2014, 6:50:41 PM7/31/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to piccolo...@googlegroups.com
Hmm, you may also have to call setOpaque(false) or Swing might be
painting over the gradient with the background color.
Or if you're already doing that, then I'm not sure and will have to
look into it further.
michael
patrick...@yahoo.com
unread,
Jul 31, 2014, 8:29:14 PM7/31/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to piccolo...@googlegroups.com
Hi Michael, setOpaque(false); does make the gradient visible; however, when this is applied to the canvas it also wipes out any PNode elements I have added to the PCanvas PLayer; i.e. makes them no longer visible, but they appear to still be part of the PCanvas PLayer object. Do I have to use different PLayers in the PCanvas for background and element components? if so could you give me a quick explanation, or point me in the right direction as to how to do this please?