Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-17-2004, 11:09 AM   #1 (permalink)
freesoft_2000
Code Monkey
 
Join Date: Oct 2004
Posts: 51
freesoft_2000 is on a distinguished road
Question JTextPane

Hi everyone,

I am trying to insert a image into the jtextpane using the html document as the default document for the jtextpane. It seems that nothing happens when i try to insert the image from disk.

htmldoc - an instance of the HTMLDocument class
TextPane1 - an instance of the JTextPane class
mas - an instance of the MutableAttributeSet class

Here is my code

The file chooser class is ok so i did not include it here

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

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

mas.addAttribute(StyleConstants.NameAttribute, HTML.Tag.IMG);
mas.addAttribute(HTML.Attribute.SRC, g.toString());
mas.addAttribute(HTML.Attribute.HEIGHT, Integer.toString(h));
mas.addAttribute(HTML.Attribute.WIDTH, Integer.toString(w));

try
{
int p = TextPane1.getCaretPosition();
htmldoc.insertString(p, " ", mas);
}

catch(Exception e)
{
}

The above code compiles without errors but does not seem to work.
Can someone tell me how to insert an image into a html document in the jtextpane or show me an example of inserting icons in a html document

Thank You

Yours Sincerely

Richard West
freesoft_2000 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JTextPane Printing freesoft_2000 Java 0 10-26-2004 08:00 AM


All times are GMT -8. The time now is 01:46 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting