JEditor pane not showing images

the following piece of code displays a directory and the link displays all the files ,if it is an image it shows the preview but actually i am not getting the image ,can any one help me?
thanks
code:
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.util.Date;
* This class implements a simple directory browser using the HTML
* display capabilities of the JEditorPane component.
public class FileTableHTML {
  public static void main(String[] args) throws IOException {
    // Get the name of the directory to display
    String dirname = (args.length>0)?args[0]:"C://Documents and Settings//400305//My Documents//SyncIT";
    // Create something to display it in.
    final JEditorPane editor = new JEditorPane();
    editor.setEditable(false);               // we're browsing not editing
    editor.setContentType("text/html");      // must specify HTML text
    editor.setText(makeHTMLTable(dirname));  // specify the text to display
    // Set up the JEditorPane to handle clicks on hyperlinks
    editor.addHyperlinkListener(new HyperlinkListener() {
      public void hyperlinkUpdate(HyperlinkEvent e) {
     // Handle clicks; ignore mouseovers and other link-related events
     if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
       // Get the HREF of the link and display it.
       editor.setText(makeHTMLTable(e.getDescription()));
    // Put the JEditorPane in a scrolling window and display it.
    JFrame frame = new JFrame("FileTableHTML");
    frame.getContentPane().add(new JScrollPane(editor));
    frame.setSize(650, 500);
    frame.setVisible(true);
  // This method returns an HTML table representing the specified directory
  public static String makeHTMLTable(String dirname) {
    // Look up the contents of the directory
    File dir = new File(dirname);
    String[] entries = dir.list();
    // Set up an output stream we can print the table to.
    // This is easier than concatenating strings all the time.
    StringWriter sout = new StringWriter();
    PrintWriter out = new PrintWriter(sout);
    // Print the directory name as the page title
    out.println("<H1>" + dirname + "</H1>");
    // Print an "up" link, unless we're already at the root
    String parent ="C://Documents and Settings//400305//My Documents//SyncIT";
    if ((parent != null) && (parent.length() > 0))
      out.println("<A HREF=\"" + parent + "\">Up to parent directory</A><P>");
    // Print out the table
    out.print("<TABLE BORDER=1  WIDTH=600 height=500><TR>");
    out.print("<TH>Name</TH><TH>Size</TH><TH>Modified</TH>");
    out.println("<TH>Readable?</TH><TH>Writable?</TH></TR>");
    for(int i=0; i < entries.length; i++) {
      File f = new File(dir, entries);
out.println("<TR><TD>" +
          (f.isDirectory() ?
                    "<a href=\""+f+"\">" + entries[i] + "</a>" : "<img src=\""+f+"\">"+
          entries[i]) +
          "</TD><TD>" + f.length() +
          "</TD><TD>" + new Date(f.lastModified()) +
          "</TD><TD align=center>" + (f.canRead()?"x":" ") +
          "</TD><TD align=center>" + (f.canWrite()?"x":" ") +
          "</TD><br><br><br><br><br></TR>");
System.out.println("<TR><TD>" +
          (f.isDirectory() ?
                    "<a href=\""+f+"\">" + entries[i] + "</a>" : "<img src=\""+f+"\" align=left width=30 height=30 border=0>"+
          entries[i]) +
          "</TD><TD>" + f.length() +
          "</TD><TD>" + new Date(f.lastModified()) +
          "</TD><TD align=center>" + (f.canRead()?"x":" ") +
          "</TD><TD align=center>" + (f.canWrite()?"x":" ") +
          "</TD><br><br><br><br><br></TR>");
//System.out.println("<img src=\""+f.toString()+"\""+" align=left width=30 height=30 border=0"+">");
out.println("</TABLE>");
out.close();
// Get the string of HTML from the StringWriter and return it.
return sout.toString();

just work on getting one simple image to .jar OK
e.g. this should .jar OK (after changing image names)
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Testing
  Image img;
  public void buildGUI()
    try
      java.net.URL url = new java.net.URL(getClass().getResource("Test.gif"), "Test.gif");
      if(url != null) img = javax.imageio.ImageIO.read(url);
    catch(Exception e){}//swallow exception - handled in paintComponent
    JPanel p = new JPanel(){
      public void paintComponent(Graphics g){
        super.paintComponent(g);
        if(img != null) g.drawImage(img,100,100,this);
        else g.drawString("this space for rent",100,100);
    JFrame f = new JFrame();
    f.getContentPane().add(p);
    f.setSize(400,300);
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  public static void main(String[] args)
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        new Testing().buildGUI();
}put the image in the same folder, make .jar, then try the .jar on another pc
if all OK, change code to locate image file in subfolder, make .jar, then try the .jar on another pc
if all OK now, modify main program accordingly.
note: in .jars, capitalization of the image file names counts
e.g. in my above example, if I change Test.gif to test.gif, the image is not drawn

Similar Messages

  • JList not showing images

    Have raised a thread giving details of the problem in Java2D forum
    JList not showing images
    Have anybody experienced this issue? I face this issue only when i use swingworker and only for small images (few kBs). It works fine for large images (More than 1MB files). I use Win 7.
    Regards,
    Sreram

    One, do you say because i set the model each time, sometimes the list is not getting repainted? I didn't say that. It's just good concurrency practice to only manipulate models on the EDT, particularly when SwingWorker easily allows the break up of loading the images in a background thread and updating the model on the EDT through the publish/process methods.
    Will the splitting up of worker as process chunks be of any use? Again it's just a good habit to get into for concurrency reasons.
    As for your repainting issue, try changing this line
    item.setImage(getImagefromFile(f)); to
    item.setImage(new ImageIcon(getImageFromFile(f)).getImage()); The ImageIcon class uses MediaTracker to synchronously load images (you can use your own if you want). If you're getting your images via the Toolkit.createImage# methods, then the images need to be loaded. Usually what happens is the toolkit image will get loaded when first drawn. The component that's doing the drawing gets repainted as more of the image comes in. But in the case of a JList, that component is the cell renderer pane and it doesn't care about repaint() calls. So changing the above line will insure the images are already loaded and ready to draw when first shown. tjacobs01 post reminded me of this.

  • My mac will not show images when on the internet?

    My mac will not show images when on the internet?  I think I have inadvertently changed some settings but nor sure which one.

    I am going to assume you are using Safari here. If so then go to the Apple menu bar and hit Safari-> Preferences.  Under the Apperance tab there is a check box that is called "Display images when the page opens".  Check if that is unticked.

  • Jdeveloper visual editor do not show images and other component shapes

    I used jdeveloper(10.1.3.3.0) to create an ADF BC application, I create a jsf jsp file and drag and drop components from ADF Faces Core to this file visual editor, but jdeveloper visual editor do not show images and other component shapes.
    Could you tell me how I can fix this problem?
    Thanks,
    Mike

    Actually, I need to make a dummy change to the jsp file and then it will display boxes representing the objects in the visual editor whereas I get an exception in the log:
    javax.servlet.jsp.JspException: Cannot find FacesContext
    This does not talk much to me !
    Thanks

  • Mobile Safari not showing images

    Hi there,
    Since upgrading to 4.01 and then 4.02 on my iPhone, Safari seems to intermittently not show images on websites... does anyone know the reason for this and a solution?

    I am having the same issue. I have found in my case the site I was working on is pulling content from JSON and the mobile app is using a Cache Manifest file. When I removed the manifest file reference I could see the images again.
    Message was edited by: Adam Randlett

  • Amazon and FaceBook not showing images

    I had a software issue and had to wipe my macbook. Since then, Safari will occasionally not show images on Amazon and sometimes FaceBook. Usually a clean of the history will fix it but sometimes it doesn't. I am not running any extensions and everything is up to date. Any idea what could be causing this?

    Hello Clement! (Be careful in what you post to the Internet, your name is in the screenshot, just sayin' If you want to be able to blur things in screenshots before posting them, try Skitch, it's a free app on the Mac App Store)
    In the past, I've seen this being caused by ISP's DNS servers.
    Try the following:
    Unplug your modem from the power, wait a minute, and plug it back in. If your issue is solved now, celebrate
    If not solved, however, try and see if you have the same issue on another network.
    You can also change the DNS server you use to something like OpenDNS. There is a guide here, preferably set it up on your router, but if that's too technical, try setting it up on your Mac only: https://store.opendns.com/setup/?__utma=247635969.764677354.1418757510.141875751 0.1418757510.1&__utmb=247635969.3.10.1418757510&__utmc=247635969&__utmx=-&__utmz =247635969.1418757510.1.1.utmcsr=google|utmccn=%28organic%29|utmcmd=organic|utmc tr=%28not%20provided%29&__utmv=-&__utmk=7372593#/
    One last thing about changing DNS servers. Really, your internet provider should be more than capable of serving you pictures from Amazon and Facebook (by the way, most of these pics are not hosted by Amazon and Facebook really, but by an outside company called Akamai that a lot of large companies use. So I should probably be saying: "your ISP should not have any trouble serving content from Akamai's servers")
    Hence, the proper advise I should give you is: contact your ISP and ask them if they've been having DNS issues lately. Barring that: you can save yourself some helpdesk pain and use OpenDNS or Google DNS.

  • The monitors of on location CS3 not showing image from Sony FX7

    O.L records OK and plays back but at no time do
    any of the monitors show an image. Was OK in Vista now gone to Windows 7
    Pre Pro CS3 ok on 7 (capture and playback.) Any suggestions please

    Dear Sir, Many many thanks for your very detailed answer everything works just fine. I'm not sure wether I should reply to your answer elsewhere please advise me if this is the case.
    thanks again William sign on name Breezley.
    Date: Mon, 4 Jan 2010 18:44:18 -0700
    From: [email protected]
    To: [email protected]
    Subject: the monitors of on location CS3 not showing image from Sony FX7
    Breezley,
    OnLocation CS3 used Direct Draw to create the video window.  In Vista, you may have noticed that OnLocation CS3 would disable 'Aero' themed desktops as they did not support Direct Draw.  Windows 7 does not have this functionality, so you must disable the Aero theme manually to see the video in OnLocation CS3.
    To do this, right click on open desktop and choose Personalize.
    This will display available Themes.
    Scroll down to the 'Basic and High Contrast Themes'.
    Choose any one of the basic or high contrast themes.
    Restart OnLocation CS3.
    This should bring your video back into view.
    >

  • Mail does not show images anymore server stopped responding on my iPad 2 when attempting to browse web

    Over the last couple of days my ipad 2 has started to play up. First the mail would not show images in mail then when trying to browse the web it now will not open any pages. I have attempted a wipe & reload but still no difference.

    Have you tried restarting or resetting your iPad?
    Restart: Press On/Off button until the Slide to Power Off slider appears, select Slide to Power Off and, after It shuts down, press the On/Off button until the Apple logo appears.
    Reset: Press the Home and On/Off buttons at the same time and hold them until the Apple logo appears (about 10 seconds).

  • Muse 7.0 plus Chrome: browser does not show images full browser width

    Hi there,
    I have a serious problem with the latest Muse version: the images which I use as parallax-masks for the background won't work with Chrome, though Safari and Firefox are not showing any problems. The issue: Chrome does either not scale the images to 100% browser-width or does not show them at all, or even shows the images cut into narrow stripes. This problem did not show in the previous version of Muse.
    Of course I already restarted application and computer. System: Mac OSX Mavericks.
    What to do now? The presentation with the client is very soon and this bug makes me very nervous.
    Best,
    bartl

    The problem bartl encountered and reported was fixed by the 7.1 release (November 21st). The problem you're describing sounds different.
    As of yet, I'm unable to reproduce what you're describing. The URL you've provided views the same in all the browsers I've tried, Chrome (32.0.1700.77) and non-Chrome, Mac and Windows.
    That said, looking at your master page I don't think you've created what you intended. At present there are two full screen slideshows on your A-master. On contains no images and the other contains a single image. Both are set to have thumbnails and the thumbnails container is off the right side of the page.
    If you look at your "Master Slideshow" layer in the Layers panel, you'll see the two slideshows. I think you'll want to delete one of them and, given your design, turn off thumbnails for the remaining one.
    Also, if you don't plan to have multiple images in the full screen slideshow, you'd be better off using a background fill image rather than the slideshow widget.
    I remain a bit puzzled how/why you're seeing different behavior in your instance of Chrome. Have you cleared your browser cache?
    On an unrelated note, if you set the page fill and stroke to none and set the browser fill to the most common color from the garage door image, it will avoid the momentary appearance of a white page on a grey background when your home page first loads. Instead the site visitor would see a blank page that's the most common color from the slideshow image, until that image loads.

  • Bridge CS3 not showing images

    Today Bridge CS3 partially stopped working.  Images do not show up in the content window but this is inconsistent.  It happens with only selected folders.  The data under filters does show the folder data.  If I try to open (clicking on) a non-existent image in the content window, PS or Camera RAW will open for that image.  I have one internal HD and 3 external LaCie drives.  Copy an affected folder to a different HD or to the desktop sometimes works but only intermittantly.  All the permits, etc. for the folders are the same, read/write permission granted and everything else the same.  Sometimes folders that previously opened do not open at a later time.
    I've tried restarting the computer and Bridge, no difference.  Two events occurred prior to the problem.  I installed Apple's latest security update and the new Adobe Reader update.  Other than that nothing particular occurred.  I am also using Lightroom2 which is working OK.  The image are in the folders OK, open in PS, etc.  They just don't show up in Bridge.
    My computer skills are medium, been user since Photoshop 6.0, taken a number of PS workshops at SFW and Maine, and am competent at using the program.  This is over my head. Help.
    Bob Gaunt

    Thanks Ramon,
    It works but with a few other problems I pretty well sorted through.  It took a couple of Bridge quit and restarts to get Bridge to open the external drives. Now that's OK.  Then it seems at times to hang up trying to generate thumbnails, have to force quit Bridge and try over.  Since Bridge worked fairly well for several years, I'm wondering what happened.  Maybe just one of life's mysteries.
    I have CS4 on the shelf, installed it and couldn't get the drivers for my Epson 2200 installed.  The CS4 included generic driver is junk, Epson quit supporting the 2200, so I re-installed CS3 for the time being.
    Bob

  • Not showing image in basic copy gif image icon and place on html page

    Trying to do a basic copy gif image icon and place it on a basic html page.
    The image shows up in my local page and shows on remote side but when I go to view in browser it does not show as a image. It shows the border but no image.
    The directions were (working with windows xp and IE8)
    Download the image to your C:\temp folder.
    4. Copy the gif file from your C:\temp folder and paste it in the same folder where your .html or .asp file is.
    I copied the image with right click save as in many different areas of computer. I even put on desktop.
    I add image and it shows on the site I am working in but when putting to remote side it does not view as an image on the browser.
    I have cleared cashe as well as pressed cntrl/refresh and still nothing.
    Other images work and show.
    on-line-vacations.com
    Thanks!

    Basic assumptions:
    You have Defined a site.
    All files reside within the defined site (including image files)
    All files use the appropriate file extensions, for example, image.gif
    You have saved and uploaded all site files to your server.
    You are EXACTLY naming the source image (no errant capital letters) in the link.
    If your other images are linking properly and showing, delete this image and insert it again (or re-link it to the image file within your site structure).
    Z

  • FF5 does not show images that are 'moved permanently' (http response 301)

    Our web app shows maps from OpenStreetmap. The webapp is secure, that is, is uses HTTPS. Now, IE complains horribly when the web page tries to load <img> via HTTP, because it's mixed content that that is considered baad.
    So our webapp serves the images by responding via HTTPS with a 301 (moved permanently) to the real OpenStreetmap URL (with is HTTP). That fools IE to not complain.
    Now, Firefox 5 suddenly does not show the map images AT ALL. This has worked beautifully with previous version (and all other browsers).
    What's wrong?

    I fixed the problem.  (YAY!)
    It was the way I embedded the files -- the Dreamweaver default does not work properly so I used the embed from this generator: http://www.bobbyvandersluis.com/swfobject/generator/index.html#alternativeContentHelp which now lets my navbar and swfobjects load properly.  I also made sure that my slideshow (loader.swf) was set with wmode = opaque while the navbar is set to wmode = transparent.  The div for the nav bar has z-index set to 5 while the div for the slideshow has z-index set to 1.  Both have absolute positioning.  I hope this helps anyone in the future that has trouble with overlaying flash (.swf) files.
    Thanks for your reply and trying to help me solve this issue!

  • Jpeg icons not showing image in My Pictures

    This hasn't happened to me before. When I edit a jpeg in Photoshop CS3 in this case, and save it in a file in My Pictures, when I go to find it again I notice there is just the Photoshop Logo instead of the actual picture image showing, not too helpful to find pictures you are looking for. It is still a jpeg but it switched from the actual picture to the logo after I saved it from Photoshop. Any tips? I'm hesitant to edit any more from my trip for fear of having to open up one at a time to see what it is!
    Thank you for any help.

    Vista 32bit is the computer I
    am on. On another reply they asked if I had the wrong Windows Explorer setting so didn't show images. All jpeg images show as downloaded from camera but when I edit and save from Photoshop, those edited images then show the PS icon only, no picture.

  • Reading pane not showing up in email on ipad

    The reading pane of my email is not showing up on my iPad how do I fix it?

    Try a reset:
    1. Hold the Sleep and Home button down (together) for about 10 seconds
    2. Until you see the Apple logo (very important)

  • Photoshop Elements 9 Editor not showing images in Project Bin

    Yesterday I went though my PE9 Organiser and rearrange some of my files and made sure that it was more user friendly.
    Today I went in to try and do some edits and not all of the folders are showing up in PE9 Project Bin. I can view some images, but not all images. I know that I can view some images that I move yesterday, but there are some that weren't moved that I can't see and some that I didn't move that i can't see.
    When i go to my Organiser I can see that the images are tagged and in the folders - why can't PE9 Editor show them to me?

    Hi,
    Can you please tell where are folders visible in Project Bin?
    I can't see folders in my PE9 project bin.
    Thanks
    andaleeb

Maybe you are looking for

  • HT2731 How can I restore my old itunes account on my new computer?

    Our old computer crashed and we now have a new one.  Am I able to find all of my itunes songs and get them on this computer if I never backed them up?

  • Deletion of messages created in solution manager service desk

    Hi All, I have implemented service desk functionality on solman 4.0. and for the testing we have created a number of messages from the satelite system. now i want to delete the messages from the list in crm_dno_monitor list. could someone help me as

  • Restart request and green and gray stripes on screen, impossible to run

    Hi. My MacBook does not start correctly. I immediately get the "you need to restart your computer message on a screen that is covered by green and grey stripes vertically. One issue I had recently is that I got close to the limit of the harddrive (1

  • Ctrl+enter doesn't work

    ctrl+enter doesn't work when I try to go to maps.yahoo.com. It only happens when I try to go here. ctrl+enter works for every other site I've tried.

  • Prevent recovery of deleted files on SSD?

    Borrowing a OS X 10.8.5 Air while I wait for a Pro replacement. Three days later I decide that it would be prudent to secure empty trash. Another day later I decide to run Disk Drill just to see what might be unearthed. Everything and more. I can't b