|
-
Oct 13th, 2006, 06:42 PM
#1
Thread Starter
Hyperactive Member
Applet Problems
Wow. It's been a while since I last posted here. ^_^
Anywho, I'm writing an applet that will act as a type of dynamice blog for my site. I realize this could be better done in Flash but when you have a POS computer like mine, Applets are the alternative.
Here is the code I have so far. This is very basic and there isn't a whole lot being displayed here but I'm still developing it.
Code:
import java.applet.*;
import java.awt.*;
public class BlogApplet extends Applet{
Font blogFont;
String[] colorState = new String[5];
String currentColorState;
Image[] iconsBlue = new Image[4];
public void init(){
blogFont = new Font("Tahoma", Font.BOLD, 12);
colorState[0] = "Blue";
colorState[1] = "Green";
colorState[2] = "Magenta";
colorState[3] = "Orange";
colorState[4] = "Yellow";
iconsBlue[0] = getImage(getCodeBase(), "computer_24Blue.gif");
iconsBlue[1] = getImage(getCodeBase(), "documents_24Blue.gif");
iconsBlue[2] = getImage(getCodeBase(), "home_24Blue.gif");
iconsBlue[3] = getImage(getCodeBase(), "mail_24Blue.gif");
currentColorState = colorState[0];
}
public void start(){}
public void stop(){}
public void destroy(){}
public void paint(Graphics g){
g.setFont(blogFont);
g.drawString(this.currentColorState, 10, 10);
g.drawImage(iconsBlue[0], 0, 0, this);
}
}
My problem is that the compiler doesn't mark it as a problem, so apparently it isn't, but the last line in the paint method must not be working or it's working and not displaying the image I tell it to because when the applet loads, it displays the current color setting (the g.drawString) but the image is no where to be found in my applet. Medic please! Thanks in advance!
Last edited by GamerMax5; Oct 15th, 2006 at 04:19 PM.
-
Oct 14th, 2006, 02:33 AM
#2
Re: Applet Problems
There is only one reason why your applet wouldn't show images. They don't exist
If you are using an IDE make sure the images are in the correct place, because the getCodeBase() returns the URL of the code attribute from the <applet> tag
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 15th, 2006, 04:19 PM
#3
Thread Starter
Hyperactive Member
Re: Applet Problems
It's working fine now. The images were there. I think it's my computer. It doesn't like to cooperate all the time, mainly because it's ancient but I have to make do with what I have so...
Thanks for the help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|