[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Reuse/Extending Mozilla.java and IE.java

Hi grant,

I tried now to subclass the IE class but now I get

java.lang.IllegalAccessError: class org.eclipse.swt.browser.IE2 cannot access its superclass org.eclipse.swt.browser.IE

What I'm doing wrong, or is it not possible to subscribe IE at all? Any idea?

Shortened code:
package org.eclipse.swt.browser;

public class Browser2 extends Browser {
    WebBrowser webBrowser;

public Browser2 (Composite parent, int style) {

    try {
	//IllegalAccess for .forName
        Class clazz = Class.forName ("org.eclipse.swt.browser.IE2");
        webBrowser = (WebBrowser)clazz.newInstance ();	
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (Throwable e) {
        e.printStackTrace();
    }
}

@Override
protected void checkSubclass() {
}

}


package org.eclipse.swt.browser;

public class IE2 extends IE {
	...
}


Regards, Philip

Grant Gayed schrieb:
Hi Philip,

See http://www.eclipse.org/swt/faq.php#subclassing and note that there is a
way to do it described at the bottom.

If you're looking to provide additional browser functionality then an
alternative approach would be to always use a Mozilla-based Browser and
program to it via JavaXPCOM.  For info about using JavaXPCOM with the
Browser see http://www.eclipse.org/swt/faq.php#howusejavaxpcom .

Grant


"Philip Chang" <philip2134@xxxxxxx> wrote in message news:g0tku8$i6b$1@xxxxxxxxxxxxxxxxxxxx
Hi,

I want to extend the existing IE/Mozilla class because I want to add
some other interfaces for both browsers.

But for doing this I figured out there is no other way than to
copy/paste them in my projet and compile it my self which is really bad.

Because I have than some references to internal classes and also in the
case of Mozilla I have dependencies via jni to native c code (Also IE
but direct in IE.java itself). Some accesses are also discouraged so...

Is there no other way than to make a copy if I want to extend but reuse
(yes I want to subclass) the existing code base?

I'm aware that I cannot expect any support from eclipse than but it
still would be great to reuse as code as much as possible without
creating dependencies on too many internal classes.

Regards,
Philip