This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Graphics
Posted by Matt Gerrans on November 20, 2001 at 2:30 AM
Check out the ImageIcon tutorial. You can easily create an ImageIcon object from a gif file (new ImageIcon("path/filename.gif") ), get an Image reference from the ImageIcon with getImage() and use Graphics.drawImage() to draw it as you wish. I've only fooled around with this a little, so I'm not sure if this is the "correct" or best way to go about this... - mfg > Does anyone know whether it's possible to create a graphics object w/ a GIF file? For a school project I have to create the Solitaire game, and I've been given simplified code for the GUI to start off. In one of the classes (the one that handles the card components), there's a method called paintComponent. It's signature and JavaDoc is: > > /** Method which overrides paint() component. > * Tells the component how to actually draw itself > * @param g The graphics object which will be painted on > */ > void paintComponent(Graphics g) >
> In the Solitaire class (which deals w/ the game logic), I shuffle a deck and I want to call paintComponent to paint the GIF file associated with each unique card. Thnx in advance. > Hiran
Replies:
|