Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2005

Tip: Looking for answers? Try searching our database.

Pictures

Thread view: 
freesoft_2000@yahoo.com - 19 Jul 2005 20:21 GMT
Hi everyone,

                  I am trying to add pictures into a html document and
so far everthing has been going well but i have a question. Wen i
insert the pictures into the html document they show up and i am able
to save them to disk in html format.

                  The thing is when i delete the picture on the disk
and read the html document the picture does not show up but if the
picture is not deleted from the disk then when i read the html document
the picture shows up.

                  Basically what i need to know if there is a way in
which i can embed a picture into the html document without any reliance
on the picture that is saved on a different location on the disk.

                 For example if the Styled Document is serialized with
an embedded picture even if the picture is deleted from the disk when
the Styled Document is read the picture is not there but this is not so
for the HTML Document class.

                  Basically my question is that is it possible to
implement something like that in which that the picture is embedded in
the HTML Document and it does not matter if the picture is deleted or
not from the disk thus even when the html document is read the embedded
picture is still there.

This is what i am doing to insert the picture into the HTML Document
Note that the file name of the picture is converted to a URL and the
Html Tag there always depend on the file name with the picture being
there

FileChooser3.setDialogType(JFileChooser.OPEN_DIALOG);
FileChooser3.setDialogTitle("Select a picture to insert into
document");

if(FileChooser3.showDialog(fr,"Insert") != JFileChooser.APPROVE_OPTION)
{
return;
}

File g = FileChooser3.getSelectedFile();
ImageIcon image1 = new ImageIcon(g.toString());

MutableAttributeSet mas1 = new SimpleAttributeSet();
//The below command line gets the width and height of the image

int w = image1.getIconWidth();
int h = image1.getIconHeight();

try
{
//The below six command line insertss the currently read in image into
//the JTextPane

mas1.addAttribute(StyleConstants.NameAttribute, HTML.Tag.IMG);
//The below command line is where the reliance occurs

mas1.addAttribute(HTML.Attribute.SRC, g.toURL().toString());
mas1.addAttribute(HTML.Attribute.HEIGHT, Integer.toString(h));
mas1.addAttribute(HTML.Attribute.WIDTH, Integer.toString(w));
int p = TextPane1.getCaretPosition();
htmldoc.insertString(p, " ", mas1);
}

catch(Exception e)
{
e.printStackTrace();
}

please note that htmldoc is an instance of the Java HTMLDocument class
and TextPane1 is an instance of the Java JTextPane class

This is its HTMl equivalent that is generated in the html document

<html>
<head>
</head>
<body>
<p>
<img height="400" width="400" src="file:/D:/Sample_Pics/venu.jpg">
</p>
</body>
</html>

See the reliance on the picture picture always being on that location
on the disk on this line

src="file:/D:/Sample_Pics/venu.jpg"

Is there a way to achieve what i need by simple ways or style sheets or
any other way??

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
Andrew Thompson - 19 Jul 2005 20:32 GMT
> Hi everyone,

See my answer on the other group.

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Too Hot For Radio

freesoft_2000@yahoo.com - 20 Jul 2005 17:39 GMT
Hi everyone,

             Andrew Thompson i don't know why you are getting angry
about as i posted the question on different forums and not on the same
forum. I know that multi-posting on the same forum is a no-no but there
is no rule on posting on other forums.

              Think about it this way. If i were to build a great car
i can't simply get all my parts from one place, i need to get the best
onboard electronic from Japan and the best engine from Germany and so
forth.

              You see the the car is the question and the places where
i get the parts are the different forums. Every forum has something
different to offer despite the question. Don't get worked up over
nothing.

              I have received a lot of e-mails regarding this topic
and a lot of people are interested in the answer as the answer can
solve a lot of portability problems.

              Don't get fed up over nothing as i hate to lose you as a
valuable Java contributing member and i encourage you to join the
discussion

Thank You

Yours Sincerely

Richard West
Andrew Thompson - 20 Jul 2005 18:39 GMT
>               Andrew Thompson i don't know why you are getting angry

Oh no - I am only mildly irritated by your annoying behaviour.
If I were angry, you would know it.

> about as i posted the question on different forums and not on the same
> forum.

Posting the same question on different forums is known
as multi-posting.  If you had followed nd read the link
I have now posted for you a mnumber of times, you might
at least have that clear.

>..I know that multi-posting on the same forum is a no-no but there
> is no rule on posting on other forums.

No!  You obviously do *not* understand.

>                Think about it this way.
[snip]

Try reading the link before you go off on more tangents
about Japanese cars.

>                Don't get fed up over nothing as i hate to lose you as a
> valuable Java contributing member and i encourage you to join the
> discussion

I encourage you not to lose the entire audience by..
- listenning carefully to advice offered[1], and discussing it
if you think it is not applicable, or you do not understand it.
- Doing so sooner, rather than later.
- [1] Including following links and reading the relevant material.
- Ceasing posting the exact same messages to *different* groups[2].

[2] Either cross-post it (if you can figure how) or settle
on *one* group.

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Bigfoot's Choice



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.