• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Adding Image, Bolds to JTextPane

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic