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 ]
posted 8 years ago
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.