Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20190323074004
20190324055304
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20190323074004
20190324055304
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
8 changes: 7 additions & 1 deletion sources/net.sf.j2s.java.core/src/java/lang/Thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,13 @@ public String toString() {
*/
public ClassLoader getContextClassLoader() {
// here if a static call during load
return JSUtil.class.getClassLoader();
ClassLoader cl = JSUtil.class.getClassLoader();
/**
* @j2sNative
*
* cl.baseClass = {getName$:function(){return "swingjs"}};
*/
return cl;
}

/**
Expand Down
31 changes: 24 additions & 7 deletions sources/net.sf.j2s.java.core/src/javax/swing/JFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,22 @@
*/
package javax.swing;

import java.awt.HeadlessException;

import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.JSFrame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.JSFrame;
import java.awt.LayoutManager;
import java.awt.event.WindowEvent;
//

import swingjs.JSUtil;
import swingjs.plaf.JSComponentUI;

//BH: Added rootPane.addNotify(); // builds a peer for the root pane
//BH: Added ability to embed the frame in a div of the web page.

/**
* An extended version of <code>java.awt.Frame</code> that adds support for
Expand Down Expand Up @@ -153,7 +150,8 @@ public class JFrame extends JSFrame implements WindowConstants,
*/
protected JRootPane rootPane;

public void add(Component comp, Object constraints) {
@Override
public void add(Component comp, Object constraints) {
if (comp instanceof JApplet) {
isAppletFrame = true;
((JApplet) comp).getLayeredPane().isFramedApplet = true;
Expand All @@ -172,6 +170,8 @@ public void add(Component comp, Object constraints) {
*/
protected boolean rootPaneCheckingEnabled = false;

private boolean _boundsFrozen;

/**
* Constructs a new frame that is initially invisible.
* <p>
Expand Down Expand Up @@ -284,6 +284,7 @@ public JFrame(String title, GraphicsConfiguration gc) {
}

public JFrame(Object object, Object object2, Object object3, Object object4) {
// For SwingJS JInternalFrame constructor
}

@Override
Expand Down Expand Up @@ -463,6 +464,7 @@ public int getDefaultCloseOperation() {
* @beaninfo bound: true hidden: true description: Mechanism for transfer of
* data into the component
*/
@Override
public void setTransferHandler(TransferHandler newHandler) {
TransferHandler oldHandler = transferHandler;
transferHandler = newHandler;
Expand All @@ -479,6 +481,7 @@ public void setTransferHandler(TransferHandler newHandler) {
* @see #setTransferHandler
* @since 1.6
*/
@Override
public TransferHandler getTransferHandler() {
return transferHandler;
}
Expand Down Expand Up @@ -914,4 +917,18 @@ protected String paramString() {
+ defaultCloseOperationString + ",rootPane=" + rootPaneString
+ ",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString;
}

public void _freezeBounds(int w, int h) {
setSize(w, h);
_boundsFrozen = true;
resizable = false;
}

@Override
public void reshape(int x, int y, int width, int height) {
if (!_boundsFrozen)
super.reshape(x, y, width, height);
}


}
42 changes: 21 additions & 21 deletions sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ public JSUtil() {


private static Map<String, Object> getFileCache() {
if (JSUtil.fileCache == null && (JSUtil.fileCache = JSUtil.J2S.getSetJavaFileCache(null)) == null) {
JSUtil.fileCache = new Hashtable<String, Object>();
JSUtil.J2S.getSetJavaFileCache(JSUtil.fileCache);
if (fileCache == null && (fileCache = J2S.getSetJavaFileCache(null)) == null) {
fileCache = new Hashtable<String, Object>();
J2S.getSetJavaFileCache(fileCache);
}
return JSUtil.fileCache;
return fileCache;
}

private static Object getCachedFileData(String path) {
return (JSUtil.useCache && JSUtil.fileCache != null ?
JSUtil.fileCache.get(path) : null);
return (useCache && fileCache != null ?
fileCache.get(path) : null);
}

/**
Expand Down Expand Up @@ -105,7 +105,7 @@ private static Object getFileContents(Object uriOrJSFile, boolean asBytes) {
data = (asBytes ? Rdr.getStreamAsBytes(stream, null) : Rdr.streamToUTF8String(stream));
} catch (Exception e) {
// bypasses AjaxURLConnection
data = JSUtil.J2S.getFileData(uri, null, false, asBytes);
data = J2S.getFileData(uri, null, false, asBytes);
}
}
return data;
Expand All @@ -120,7 +120,7 @@ private static Object getFileContents(Object uriOrJSFile, boolean asBytes) {
*/
public static String getFileAsString(String filename) {
Object data = getFileContents(filename, false);
return JSUtil.ensureString(data);
return ensureString(data);
}

public static byte[] getFileAsBytes(Object file, boolean checkNotFound) {
Expand Down Expand Up @@ -167,7 +167,7 @@ else if (data instanceof InputStream)
}

public static boolean haveCachedResource(String resourceName, boolean isJavaPath) {
String path = JSUtil.J2S.getResourcePath(resourceName, isJavaPath);
String path = J2S.getResourcePath(resourceName, isJavaPath);
return (path != null && getCachedFileData(path) != null);
}

Expand All @@ -192,14 +192,14 @@ public static String getJavaResource(String resourceName, boolean isJavaPath,
if (data == null
&& (data = J2S.getFileData(path, null, false, false)) != null
&& useCache && doCache)
JSUtil.cacheFileData(path, data);
String sdata = JSUtil.ensureString(data);
cacheFileData(path, data);
String sdata = ensureString(data);
boolean ok = (sdata != null && sdata.indexOf("[Exception") != 0);
System.out.println("Processing " + path + " ["
+ (ok ? "" + sdata.length() : sdata) + "]");
return (!ok ? null : !doProcess ? sdata
: path.endsWith(".css") ? JSUtil.processCSS(sdata, path) : path
.endsWith(".js") ? JSUtil.processJS(sdata, resourceName) : sdata);
: path.endsWith(".css") ? processCSS(sdata, path) : path
.endsWith(".js") ? processJS(sdata, resourceName) : sdata);
}

static void cacheFileData(String path, Object data) {
Expand All @@ -224,7 +224,7 @@ public static void loadJavaResourcesFromZip(ClassLoader cl, String zipFileName,
try {
BufferedInputStream bis = new BufferedInputStream(cl.getResourceAsStream(zipFileName));
String prefix = J2S.getResourcePath(null, true); // will end with /
fileList = JSUtil.getZipTools().cacheZipContentsStatic(bis, prefix, mapByteData, false);
fileList = getZipTools().cacheZipContentsStatic(bis, prefix, mapByteData, false);
} catch (Exception e) {
System.out.println("JSUtil could not cache files from " + zipFileName);
return;
Expand Down Expand Up @@ -260,7 +260,7 @@ static String processCSS(String css, String path) {
path = path.substring(0, path.lastIndexOf("/") + 1) + "images/";
css = PT.rep(css, "images/", path);
}
JSUtil.jQuery.$("head").append(JSUtil.jQuery.$("<style type='text/css'>" + css + "</style>"));
jQuery.$("head").append(jQuery.$("<style type='text/css'>" + css + "</style>"));
return css;
}

Expand All @@ -276,7 +276,7 @@ static String processJS(String js, String resourceName) {
*/
{}
} catch (Throwable e) {
JSUtil.alert("error processing " + js);
alert("error processing " + js);
return null;
}
return js;
Expand Down Expand Up @@ -348,8 +348,8 @@ public static String getStackTrace() {
*/
public static void notImplemented(String msg) {
String s = null;
if (JSUtil.mapNotImpl == null)
JSUtil.mapNotImpl = new Hashtable<String, Boolean>();
if (mapNotImpl == null)
mapNotImpl = new Hashtable<String, Boolean>();
/**
* @j2sNative
*
Expand All @@ -360,9 +360,9 @@ public static void notImplemented(String msg) {
*/
{
}
if (JSUtil.mapNotImpl.containsKey(s))
if (mapNotImpl.containsKey(s))
return;
JSUtil.mapNotImpl.put(s, Boolean.TRUE);
mapNotImpl.put(s, Boolean.TRUE);
System.out.println(s + " has not been implemented in SwingJS. "
+ (msg == "" ? "" : (msg == null ? "" : msg) + getStackTrace(-5)));

Expand Down Expand Up @@ -509,7 +509,7 @@ public static void showWebPage(URL url, Object target) {
* @param msg
*/
public static void warn(String msg) {
JSUtil.alert(msg);
alert(msg);
}

/**
Expand Down
23 changes: 15 additions & 8 deletions sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,7 @@ protected void setMnemonic(int newValue) {

private boolean ignoreFocus;

protected DOMNode embeddingNode;

/**
* we can allow frames -- particularly JInternalFrames in a JDesktopFrame -- to overflow.
Expand Down Expand Up @@ -1704,7 +1705,7 @@ protected DOMNode setHTMLElementCUI() {
// If the applet's root pane, we insert it into the applet's
// content
DOMNode cdiv = swingjs.JSToolkit.getHTML5Applet(jc)._getContentLayer();
DOMNode.appendChildSafely(cdiv, outerNode);
DOMNode.appendChildSafely(cdiv, outerNode);
}
}
}
Expand All @@ -1716,6 +1717,9 @@ protected DOMNode setHTMLElementCUI() {
}
}
isTainted = false;

if (embeddingNode != null)
DOMNode.appendChildSafely(embeddingNode, outerNode);
return outerNode;
}

Expand Down Expand Up @@ -1763,7 +1767,8 @@ protected void addChildrenToDOM(Component[] children, int n) {
} else {
if (ui.domNode != ui.outerNode && DOMNode.getParent(ui.domNode) == null)
appendChild(ui.outerNode, ui.domNode);
DOMNode.appendChildSafely(containerNode, ui.outerNode);
if (ui.embeddingNode == null)
DOMNode.appendChildSafely(containerNode, ui.outerNode);
}
}
}
Expand Down Expand Up @@ -2128,7 +2133,7 @@ public void setBounds(int x, int y, int width, int height, int op) {
case SET_LOCATION:
x = c.getX();
y = c.getY();
if (this.x != x || this.y != y) {
if (embeddingNode == null && (this.x != x || this.y != y)) {
this.x = x;
this.y = y;
}
Expand Down Expand Up @@ -2192,15 +2197,17 @@ private ImageIcon getIcon(JSComponent c, Icon icon) {

/**
* remove 0x0000 and replace space with nonbreaking space if not a textarea
*
* @param t
* @return
*/
protected String fixText(String t) {
t = (t != null && t.indexOf("\u0000") >= 0 ? PT.rep(t, "\u0000", "") : t);
if (isHTML) {
//
} else if (valueNode == null) {
t = t.replace(' ', '\u00A0');
if (t != null) {
if (isHTML) {
//
} else if (valueNode == null) {
t = (t.indexOf("\u0000") >= 0 ? PT.rep(t, "\u0000", "") : t).replace(' ', '\u00A0');
}
}
return t;
}
Expand Down
Loading