Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

images

 
sara e
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have just completed an applet with an image. Within the applet, I use getCodeBase and properly paint the image on the applet. However, when I open up the html page with IE that I embedded my applet in, my image does not show up. A white box the size of my applet shows up to the left of the applet. I was wondering what html code I would use to properly place my image on top of my applet. I would greatly appreciate any suggestions. Thank you very much!!
Here is my html code:
inside the applet tag
CODEBASE = "Java Classes"
CODE = "Graph.class"
NAME = "Graph"
WIDTH = "450"
HEIGHT = "450"
HSPACE = 0
VSPACE = 0
ALIGN = absmiddle
end of applet tag
Next I have my image
IMG SOURCE=freq VALUE="image/image002.gif" WIDTH="190" HEIGHT="50" ALIGN=CENTER
Thanks for all your help!! -sara
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your CODEBASE attribute might be wrong... CODEBASE is used to define where your class file is relative to the web page containing the applet tag. i.e. If your web page is in the ~sara directory, and your class file is in the ~sara/java directory, then your CODEBASE attribute should look like "CODEBASE=java". If your class is in the same directory, you can leave CODEBASE out completely, or set it to the current directory ( with a "CODEBASE=." ). Also, if the image is in the directory ~sara/images ( as it looks like it is from the HTML you posted ) then you'll need to use to get the image from there. getCodeBase() returns the URL of the class, getDocumentBase() returns the URL of the web page that launched the applet.

HTH,
-Nate

P.S. - Please read the JavaRanch naming conventions and re-register with a name that follows them. We require a user name to be in the form "first name" + space + "last name", where both first and last name are longer than one letter... Thanks!
[This message has been edited by Nathan Pruett (edited August 09, 2001).]
 
sara edison
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nate! I greatly appreciate your advice on the images and the name
 
sara edison
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The image shows up now, but I can't get it in the right position. Any ideas how to position the image with html?
nate - thanks for your help!!!
Here is my code:
Beginning of applet tag
CODE = "Graph.class"
NAME = "Graph"
WIDTH = "450"
HEIGHT = "450"
HSPACE = 0
VSPACE = 0
ALIGN = absmiddle
end of applet tag
IMG SRC="graph.gif" WIDTH="191" HEIGHT="41">
I appreciate any suggestions!!! Thanks!!! - sara
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's one of the drawbacks of HTML... It only describes the content, not the layout of the document. There are a few things you can do to affect the layout, though... You can use HTML table tags to add "buffer" space and get your image in a better position. You can also use CSS ( Cascading Style Sheets ) to define the layout of your page.

Exactly what do you want the layout of your page to look like?
 
sara edison
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want the page to consist of my applet with the image placed in the middle of the right hand side of the applet. I have allocated space for this image with my layout manager in my applet. I'll try the buffering and CSS and see how it goes. Thanks for you suggestions!!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From what you're saying, you're trying to draw an image on top of the applet in the web page? Why not draw the image in the applet? I don't know if you can do what you are trying to do with HTML, and it would be alot simpler to just load the image into the applet and draw it...

Applet has getImage() methods to load the image, and you would just have to draw the image in your paint() method (or use a custom component to draw it if you have a GUI or something it needs to fit in, check this post out if you need help on this... ). It's going to be alot easier to do what you want either of these ways...

HTH,
-Nate
 
sara edison
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do actually draw my image in my applet and when I run it with a CodeWarrior/TextPad/Forte, the image shows up fine. I have the getImage and paint as described in the post. When I try to open the applet up in Internet Explorer or Netscape, my image disappears. I am new to java so I thought one way to make it show up would be to use html. I just can't figure out why my image disappears . Anyways, thanks for all you help Nate!! I really appreciate it!!
 
sara edison
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured out why my image was disappearing! It was not saved in the typical gif 87 or 89 formats thus there was no global colormap and it would not show up. I didn't need to include an image tag in my html since I had already drawn it in my applet. Thanks for all your help Nate!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic