File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
sources/net.sf.j2s.java.core/src/a2s Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 22
33import java .awt .Graphics ;
44import java .awt .HeadlessException ;
5+ import java .net .MalformedURLException ;
6+ import java .net .URL ;
57
68import javax .swing .JApplet ;
79import javax .swing .JPanel ;
@@ -57,4 +59,23 @@ protected void paintMe(Graphics g) {
5759 System .out .println ("paintMe has not been implemented!" );
5860 }
5961
62+
63+ /**
64+ * fix for applet running in Eclipse, which unfortunately uses /bin/ for the codeBase
65+ *
66+ */
67+ @ Override
68+ public URL getCodeBase () {
69+ String codeBase = super .getCodeBase ().toString ();
70+ if (codeBase .endsWith ("/bin/" )) {
71+ String appletPath = this .getClass ().getName ();
72+ codeBase += appletPath .substring (0 , appletPath .lastIndexOf ("." ) + 1 ).replace ('.' , '/' );
73+ }
74+ try {
75+ return new URL (codeBase );
76+ } catch (MalformedURLException e ) {
77+ return null ;
78+ }
79+
80+ }
6081}
You can’t perform that action at this time.
0 commit comments