#11 Problems showing images

closed-works-for-me
nobody
None
5
2008-01-07
2007-07-29
Sergej Kotliar
No

Hi!

This is probably not a bug report, but I'm posting it here as instructed in:
http://sourceforge.net/forum/forum.php?thread_id=1786749&forum_id=467020

Please have a look at it, I'm attaching a jar file that needs to be in the same dir as cobra.jar and js.jar, which you should have. This jar file contains both source code (RSVP.java) and binary to run it.

Also, if you're already looking into it, any ideas as to why when links are clicked, the target websites don't open?

Quick users manual for this buggy piece of browser:
type in an adress, wait for it to load, and then press the start button in the bottom right of the screen.
Note that the displaying of content stops whenever and image is to be shown, which will show a blank space on the screen.

If you're able to help, I'd be very appreciative!

Best,
Sergej Kotliar

Discussion

  • Logged In: YES
    user_id=1837185
    Originator: NO

    Sorry for the late response. When I try to open the JAR file I get an error message that says "Invalid or corrupt JAR file". Is the JAR file 62Kb in size?

     
  • Sergej Kotliar
    Sergej Kotliar
    2007-08-13

    Logged In: YES
    user_id=895206
    Originator: YES

    No, it's supposed to be 104,5 KB.

    Tried downloading it here, worked fine. Will upload again, just in case. It's supposed to be placed in the lib folder that has cobra.jar and js.jar.

    File Added: RSVP.jar

     
  • Sergej Kotliar
    Sergej Kotliar
    2007-08-13

    Second try

     
    Attachments
  • Logged In: YES
    user_id=1837185
    Originator: NO

    Sorry, there must be a problem with SF's upload functionality. The second file is corrupted as well.

     
    • status: open --> closed-works-for-me
     
  • Logged In: YES
    user_id=1837185
    Originator: NO

    I tried downloading the attachment now and it worked, but I couldn't run the program. The version of Cobra the program was built for seems to be old. Now, what I did is try to reproduce the bug based on the original forum discussion. I came up with the following code:

    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    import java.net.URL;
    import java.net.URLConnection;

    import org.lobobrowser.html.*;
    import org.lobobrowser.html.gui.*;
    import org.lobobrowser.html.parser.*;
    import org.lobobrowser.html.test.*;
    import org.lobobrowser.html.domimpl.*;
    import org.w3c.dom.Document;
    import org.xml.sax.InputSource;

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;

    /**
    * Minimal rendering example: google.com.
    */
    public class CobraImageTest {
    public static void main(String[] args) throws Exception {
    String uri = "http://lobobrowser.org";
    URL url = new URL(uri);
    URLConnection connection = url.openConnection();
    InputStream in = connection.getInputStream();

    Reader reader = new InputStreamReader(in);

    InputSource is = new InputSourceImpl(reader, uri);
    HtmlPanel htmlPanel = new HtmlPanel();
    HtmlRendererContext rendererContext = new LocalHtmlRendererContext(htmlPanel);

    htmlPanel.setPreferredWidth(800);

    DocumentBuilderImpl builder = new DocumentBuilderImpl(rendererContext.getUserAgentContext(), rendererContext);
    Document document = builder.parse(is);
    in.close();

    htmlPanel.setDocument(document, rendererContext);

    final JFrame frame = new JFrame();
    frame.getContentPane().add(htmlPanel);

    EventQueue.invokeLater(new Runnable() {
    public void run() {
    frame.pack();
    frame.setVisible(true);
    }
    });

    // Test follows: Programmatically add image
    // to document.

    final HTMLElementImpl element = (HTMLElementImpl) document.getElementById("thediv");
    ActionListener action = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    element.setInnerHTML("<img style=\"border: 1px solid black;\" src=\"http://www.google.se/images/hp0.gif\" width=\"100\" height=\"30\" alt=\"Google\"/>");
    }
    };
    javax.swing.Timer timer = new javax.swing.Timer(3000, action);
    timer.setRepeats(false);
    timer.start();
    }

    private static class LocalHtmlRendererContext extends SimpleHtmlRendererContext {
    public LocalHtmlRendererContext(HtmlPanel contextComponent) {
    super(contextComponent);
    }
    }
    }

    This code worked. Images can be set dynamically and programmatically in Java. Therefore, I'm closing the bug as unreproducible.