[java] loading .gif getting error
Error: C:\VisualCafe\Projects\SimplCon.java(20): Undefined variable or class name: Lion1
I dragged and dropped the .gif file into
the "project window" -I''m in visual cafe on my PC today
-instead of my Macs
public void paint(Graphics g){
g.drawimage(Lion1.gif,100,150,this);
}
I guess I have to "declare" the .gif as a variable?
I know, I Know, I should know this, but I don''t and my head
may implode for lack of something (ceratonin?) at any time
_________________________________________________________________
ELF shot the FOOOOOOOOOOOOOOOOOOOD!
"do you like my helmut?"-yoghurt
___________________________________________________________________-
//trying GetImage
import java.awt.Rectangle;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.SystemColor;
public class SimplCon {
Image lion = getImage(getCodeBase(),"LION1.gif");
public SimplCon () {
}
static public void main(String args[]) {
System.out.println("Hello World");
}
public void paint(Graphics g){
g.drawimage(lion,100,150,this);
}
}
_____________________________________________________________--
//doesnt work
//Error: C:\VisualCafe\Projects\SimplCon.java(11): Class Image not found in type declaration
//Error: C:\VisualCafe\Projects\SimplCon.java(11): Method getCodeBase() not found in SimplCon
Error: C:\VisualCafe\Projects\SimplCon.java(23): Method drawimage(Image, int, int, SimplCon) not found in java.awt.Graphics
3 error(s), 0 warning(s)
Build Failed
________________________________________________________________
Elf Shot the Food...(again)
Edited by - lupine on December 1, 2000 7:43:45 PM
//trying GetImage
import java.awt.Rectangle;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.SystemColor;
public class SimplCon {
Image lion = getImage(getCodeBase(),"LION1.gif");
public SimplCon () {
}
static public void main(String args[]) {
System.out.println("Hello World");
}
public void paint(Graphics g){
g.drawimage(lion,100,150,this);
}
}
_____________________________________________________________--
//doesnt work
//Error: C:\VisualCafe\Projects\SimplCon.java(11): Class Image not found in type declaration
//Error: C:\VisualCafe\Projects\SimplCon.java(11): Method getCodeBase() not found in SimplCon
Error: C:\VisualCafe\Projects\SimplCon.java(23): Method drawimage(Image, int, int, SimplCon) not found in java.awt.Graphics
3 error(s), 0 warning(s)
Build Failed
________________________________________________________________
Elf Shot the Food...(again)
Edited by - lupine on December 1, 2000 7:43:45 PM
"do you like my helmut?"-yoghurt
I can fix one of your problems...
g.drawImage(lion,x,y,->null<-);
THe final paramater to drawImage needs to be of type ImageObserver or null.
Good luck
g.drawImage(lion,x,y,->null<-);
THe final paramater to drawImage needs to be of type ImageObserver or null.
Good luck
Image lion = getImage(getCodeBase(),"LION1.gif");
Your class needs to extend Applet for this line to be okay.
If you don''t want an Applet, use
Image lion = getToolkit().getImage("LION1.gif");
is used in apps, but have to extends Frame etc..
Also make sure to import java.awt.Image , or nothing will work at all... Todd.
Your class needs to extend Applet for this line to be okay.
If you don''t want an Applet, use
Image lion = getToolkit().getImage("LION1.gif");
is used in apps, but have to extends Frame etc..
Also make sure to import java.awt.Image , or nothing will work at all... Todd.
thanks for your help everyone
yes, I do need an applet. I had been assuming that
applets and applications were mutually exclusive.
Now that I know I can use applets in my application
things will be much easier for me.
Sorry I''m a bit thick, oh and lets not forget slow to
process...did I mention that I can''t draw anime style?
________________________________________________________________
Elf shot the potion!
"ELF! wtf are you doing!?!"
12 years old "uh, sorry"
yes, I do need an applet. I had been assuming that
applets and applications were mutually exclusive.
Now that I know I can use applets in my application
things will be much easier for me.
Sorry I''m a bit thick, oh and lets not forget slow to
process...did I mention that I can''t draw anime style?
________________________________________________________________
Elf shot the potion!
"ELF! wtf are you doing!?!"
12 years old "uh, sorry"
"do you like my helmut?"-yoghurt
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement