Article View: borland.public.jbuilder.java.swing
Article #8936Re: Rotate Image
From: JPBallet
Date: Mon, 03 Jul 2000 00:00
Date: Mon, 03 Jul 2000 00:00
50 lines
2144 bytes
2144 bytes
Thank's for all but my JPanel Affiche class is a class which works fine
with all kind of image of all format (more height an with that the JPanel..)
but for 2 images which are rotate when apply the same paintComponent method
i have the message following on the Graphics2D g2d = (Graphics2D) g;
line :
java.lang.ClassCastException:javax.swing.DebugGraphics at...
paintComponent..
Who does say me why?
Thanks
Jean-Pierre Ballet
> import java.net.*;
> import java.awt.*;
> import javax.swing.*;
>
> public class RotateTest
> extends JPanel
> {
> private Image image;
>
> public static void main( String[] args ) {
> JFrame frame = new JFrame();
> frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
> frame.setSize( 300, 300 );
> frame.setLocation( 200, 200 );
>
> frame.getContentPane().add( new RotateTest() );
> frame.validate();
> frame.show();
> }
>
> public RotateTest() {
> URL url = getClass().getResource( "Test.gif" );
> image = Toolkit.getDefaultToolkit().createImage( "Test.gif" );
> }
>
> public void paintComponent( Graphics g ) {
> super.paintComponent( g );
> Graphics2D g2d = (Graphics2D) g;
> Dimension size = getSize();
> g2d.rotate( Math.PI / 2 );
> g2d.translate( 0, - size.width );
> g.drawImage( image, 0, 0, size.height, size.width, this );
> }
> }
>
>--
>John P. McGrath
><JPMcGrath@fast.net>
><jpm@nscs.fast.net>
Technical Details
Message-ID:
<8jpfpn$cuo4@bornews.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8j9gmh$d9q13@bornews.borland.com> <39586810.D1A762EE@cwcom.co.uk> <8j9s77$ifp7@bornews.borland.com> <MPG.13c7666614657863989a06@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,ef6b50d79cf9fa21 X-Google-Attributes: gid111d45,public From: "JPBallet" <jean-pierre.ballet@meteo.fr> Subject: Re: Rotate Image Date: 2000/07/03 Message-ID: <8jpfpn$cuo4@bornews.borland.com> X-Deja-AN: 641734875 References: <8j9gmh$d9q13@bornews.borland.com> <39586810.D1A762EE@cwcom.co.uk> <8j9s77$ifp7@bornews.borland.com> <MPG.13c7666614657863989a06@forums.borland.com> Organization: METEO-FRANCE X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: borland.public.jbuilder.java.swing