Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Manipulate Graphics2D object to change subsequent painting operations

800390Dec 5 2008 — edited Dec 11 2008
Hello,

I'm trying to manipulate a Graphics2D object to change all subsequent painting operations. Particularly, I have just overwritten the "paint(Graphics g)" method of the JDialog class, which looks that way:
@Override
public void paint( Graphics g )
{
    Graphics2D g2d = (Graphics2D)g.create();
    g2d.translate( 100, 100 );
 
    super.paint( g2d );
}
Now I exptected all drawings within the JDialog to be translated by 100,100 pixels (e.g. a simple JButton). But this does not work, the "g2d.translate( 100, 100 );" does not have any effect on the subsequent drawings done by "super.paint( g2d );".

Does anyone know, why this isn't working? Is it even possible to do something like that?

(My intention is to draw a picture on the JDialog, and then draw the contents of the JDialog (all the components) on top of it with half the alpha value with the AlphaComposite class)


Thanks a lot for your help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 8 2009
Added on Dec 5 2008
10 comments
269 views