Mark Peters
Mark Peters

Reputation: 81104

showDocument() does not display new window in IE8 with Java 7/Java 6u27

I have a Java Applet that interacts with the Java Plugin to show a document (just a URL) in a named browser window:

public class TestApplet extends Applet {
    @Override
    public void init() {
        super.init();

        final JButton showButton = new JButton("Show Google!");

        showButton.addActionListener(new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                try {
                    getAppletContext().showDocument(new URL("http://google.com"), "Some Window Title");
                } catch (MalformedURLException e1) {
                    e1.printStackTrace();
                }
            }
        });

        add(showButton);
    }
}

This has worked historically but starting with Java 7 and Java 6u27, the window fails to open in Internet Explorer (tested in IE 8). If I use _blank as the window title (target) instead of Google, the window opens correctly (albeit in a new window each time).

I've tracked down this bug that was fixed for 6u27:

Has anybody else experienced the same behaviour? Have you found a workaround (other than using "_blank")?

Edit

Updated the example. I wasn't actually using "Google" as the target, I was using "Some Window Title" (sorry!). It seems like this problem is unique to targets with spaces in the name.

Upvotes: 0

Views: 1131

Answers (2)

Naveen
Naveen

Reputation: 11

Try this code, it should work.

Desktop desktop = Desktop.getDesktop();
        desktop.browse(new URI(info));

Upvotes: 1

Andrew Thompson
Andrew Thompson

Reputation: 168835

It seems like this problem is unique to targets with spaces in the name.

Two possible solutions:

  1. Replace the " " with "%20"
  2. Don't use a space in the name of the target! (Though I thought that would be a 'no brainer'.)

Upvotes: 1

Related Questions