This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding Image, Bolds to JTextPane

 
Scott Florez
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I'm using the code below to generate a JTextPane. However, the image is not being displayed at the top of the pane. I'm trying to read the image from the current working directory (not a URL). I've tried every possible path I can think of. I'm not getting any errors when I try to read the image; it just doesn't show up. The bolds also aren't showing up as bold. Can anyone help? Thanks!


[ March 01, 2007: Message edited by: Scott Florez ]
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried your code and it worked okay. Both the image and the bold text appeared as
expected.
About image loading, the getResource methods search the class path for the image. If the
File(path) cannot be found you would likely get a message from your createImageIcon
method.
However, if ImageIcon cannot decipher the file or load the data it says nothing. You have
to ask it how the loading went. Here's an idea for the asking part:

That the bold text did not appear suggests something else. You can get the StyledDocument
from the JTextPane and query it for the Styles it contains. Write out the attributes to
see if they match what you put in.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic