getManagingFocusBackwardTraversalKeys() {
}
private static Rectangle fetchRectangle() {
- synchronized (tempRectangles) {
+ synchronized (_tempRect) {
Rectangle rect;
- int size = tempRectangles.size();
+ int size = _tempRect.size();
if (size > 0) {
- rect = (Rectangle) tempRectangles.removeItemAt(size - 1);
+ rect = (Rectangle) _tempRect.removeItemAt(size - 1);
} else {
rect = new Rectangle(0, 0, 0, 0);
}
@@ -433,8 +435,8 @@ private static Rectangle fetchRectangle() {
}
private static void recycleRectangle(Rectangle rect) {
- synchronized (tempRectangles) {
- tempRectangles.addLast(rect);
+ synchronized (_tempRect) {
+ _tempRect.addLast(rect);
}
}
@@ -496,8 +498,8 @@ public void setComponentPopupMenu(JPopupMenu popup) {
if (popup != null) {
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
}
- JPopupMenu oldPopup = this.popupMenu;
- this.popupMenu = popup;
+ JPopupMenu oldPopup = this._popupMenu;
+ this._popupMenu = popup;
firePropertyChange("componentPopupMenu", oldPopup, popup);
}
@@ -516,10 +518,10 @@ public void setComponentPopupMenu(JPopupMenu popup) {
public JPopupMenu getComponentPopupMenu() {
if (!getInheritsPopupMenu()) {
- return popupMenu;
+ return _popupMenu;
}
- if (popupMenu == null) {
+ if (_popupMenu == null) {
// Search parents for its popup
Container parent = getParent();
while (parent != null) {
@@ -535,7 +537,7 @@ public JPopupMenu getComponentPopupMenu() {
return null;
}
- return popupMenu;
+ return _popupMenu;
}
/**
@@ -1588,9 +1590,9 @@ public boolean contains(int x, int y) {
* description: The component's border.
*/
public void setBorder(Border border) {
- Border oldBorder = this.border;
+ Border oldBorder = this._border;
- this.border = border;
+ this._border = border;
firePropertyChange("border", oldBorder, border);
if (border != oldBorder) {
if (border == null
@@ -1611,7 +1613,7 @@ public void setBorder(Border border) {
* @see #setBorder
*/
public Border getBorder() {
- return border;
+ return _border;
}
/**
@@ -1623,8 +1625,8 @@ public Border getBorder() {
*/
@Override
public Insets getInsets() {
- if (border != null) {
- return border.getBorderInsets(this);
+ if (_border != null) {
+ return _border.getBorderInsets(this);
}
return super.getInsets();
}
@@ -1651,17 +1653,17 @@ public Insets getInsets(Insets insets) {
// because AWT components do not have this method
in = getInsets();
} else {
- if (border == null) {
+ if (_border == null) {
// super.getInsets() always returns an Insets object with
// all of its value zeroed. No need for a new object here.
insets.left = insets.top = insets.right = insets.bottom = 0;
} else {
- if (border instanceof AbstractBorder) {
- in = ((AbstractBorder) border).getBorderInsets(this, insets);
+ if (_border instanceof AbstractBorder) {
+ in = ((AbstractBorder) _border).getBorderInsets(this, insets);
}
// Can't reuse border insets because the Border interface
// can't be enhanced.
- in = border.getBorderInsets(this);
+ in = _border.getBorderInsets(this);
}
}
if (in != null) {
@@ -1683,8 +1685,8 @@ public Insets getInsets(Insets insets) {
*/
@Override
public float getAlignmentY() {
- if (isAlignmentYSet) {
- return alignmentY;
+ if (_isAlignmentYSet) {
+ return _alignmentY;
}
return super.getAlignmentY();
}
@@ -1698,9 +1700,9 @@ public float getAlignmentY() {
* @beaninfo description: The preferred vertical alignment of the component.
*/
public void setAlignmentY(float alignmentY) {
- this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f
+ this._alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f
: alignmentY;
- isAlignmentYSet = true;
+ _isAlignmentYSet = true;
}
/**
@@ -1713,8 +1715,8 @@ public void setAlignmentY(float alignmentY) {
*/
@Override
public float getAlignmentX() {
- if (isAlignmentXSet) {
- return alignmentX;
+ if (_isAlignmentXSet) {
+ return _alignmentX;
}
return super.getAlignmentX();
}
@@ -1728,9 +1730,9 @@ public float getAlignmentX() {
* @beaninfo description: The preferred horizontal alignment of the component.
*/
public void setAlignmentX(float alignmentX) {
- this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f
+ this._alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f
: alignmentX;
- isAlignmentXSet = true;
+ _isAlignmentXSet = true;
}
/**
@@ -2958,8 +2960,8 @@ public void scrollRectToVisible(Rectangle aRect) {
*/
public void setAutoscrolls(boolean autoscrolls) {
setFlag(AUTOSCROLLS_SET, true);
- if (this.autoscrolls != autoscrolls) {
- this.autoscrolls = autoscrolls;
+ if (this._autoscrolls != autoscrolls) {
+ this._autoscrolls = autoscrolls;
if (autoscrolls) {
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
@@ -2977,7 +2979,7 @@ public void setAutoscrolls(boolean autoscrolls) {
* @see #setAutoscrolls
*/
public boolean getAutoscrolls() {
- return autoscrolls;
+ return _autoscrolls;
}
/**
@@ -2993,7 +2995,7 @@ public boolean getAutoscrolls() {
*/
@Override
protected void processMouseEvent(MouseEvent e) {
- if (autoscrolls && e.getID() == MouseEvent.MOUSE_RELEASED) {
+ if (_autoscrolls && e.getID() == MouseEvent.MOUSE_RELEASED) {
Autoscroller.stop(this);
}
super.processMouseEvent(e);
@@ -3009,7 +3011,7 @@ protected void processMouseEvent(MouseEvent e) {
@Override
protected void processMouseMotionEvent(MouseEvent e) {
boolean dispatch = true;
- if (autoscrolls && e.getID() == MouseEvent.MOUSE_DRAGGED) {
+ if (_autoscrolls && e.getID() == MouseEvent.MOUSE_DRAGGED) {
// We don't want to do the drags when the mouse moves if we're
// autoscrolling. It makes it feel spastic.
dispatch = !Autoscroller.isRunning(this);
@@ -4164,7 +4166,7 @@ public void removeNotify() {
RepaintManager.currentManager(this).resetDoubleBuffer();
setCreatedDoubleBuffer(false);
}
- if (autoscrolls) {
+ if (_autoscrolls) {
Autoscroller.stop(this);
}
}
@@ -4680,15 +4682,15 @@ boolean checkIfChildObscuredBySibling() {
private void setFlag(int aFlag, boolean aValue) {
if (aValue) {
- flags |= (1 << aFlag);
+ _flags |= (1 << aFlag);
} else {
- flags &= ~(1 << aFlag);
+ _flags &= ~(1 << aFlag);
}
}
private boolean getFlag(int aFlag) {
int mask = (1 << aFlag);
- return ((flags & mask) == mask);
+ return ((_flags & mask) == mask);
}
// // These functions must be static so that they can be called from
@@ -4754,11 +4756,11 @@ protected String paramString() {
.toString() : "");
String maximumSizeString = (isMaximumSizeSet() ? getMaximumSize()
.toString() : "");
- String borderString = (border == null ? "" : (border == this ? "this"
- : border.toString()));
+ String borderString = (_border == null ? "" : (_border == this ? "this"
+ : _border.toString()));
- return super.paramString() + ",alignmentX=" + alignmentX + ",alignmentY="
- + alignmentY + ",border=" + borderString + ",flags=" + flags
+ return super.paramString() + ",alignmentX=" + _alignmentX + ",alignmentY="
+ + _alignmentY + ",border=" + borderString + ",flags=" + _flags
+ // should beef this up a bit
",maximumSize=" + maximumSizeString + ",minimumSize="
+ minimumSizeString + ",preferredSize=" + preferredSizeString;
diff --git a/sources/net.sf.j2s.java.core/src/javax/swing/JFrame.java b/sources/net.sf.j2s.java.core/src/javax/swing/JFrame.java
index 5739327a6..a3255e772 100644
--- a/sources/net.sf.j2s.java.core/src/javax/swing/JFrame.java
+++ b/sources/net.sf.j2s.java.core/src/javax/swing/JFrame.java
@@ -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 java.awt.Frame that adds support for
@@ -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;
@@ -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.
*
@@ -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
@@ -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;
@@ -479,6 +481,7 @@ public void setTransferHandler(TransferHandler newHandler) {
* @see #setTransferHandler
* @since 1.6
*/
+ @Override
public TransferHandler getTransferHandler() {
return transferHandler;
}
@@ -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);
+ }
+
+
}
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java b/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java
index 0e9ea128b..522277dda 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java
@@ -56,16 +56,16 @@ public JSUtil() {
private static Map getFileCache() {
- if (JSUtil.fileCache == null && (JSUtil.fileCache = JSUtil.J2S.getSetJavaFileCache(null)) == null) {
- JSUtil.fileCache = new Hashtable();
- JSUtil.J2S.getSetJavaFileCache(JSUtil.fileCache);
+ if (fileCache == null && (fileCache = J2S.getSetJavaFileCache(null)) == null) {
+ fileCache = new Hashtable();
+ 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);
}
/**
@@ -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;
@@ -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) {
@@ -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);
}
@@ -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) {
@@ -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;
@@ -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.$(""));
+ jQuery.$("head").append(jQuery.$(""));
return css;
}
@@ -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;
@@ -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();
+ if (mapNotImpl == null)
+ mapNotImpl = new Hashtable();
/**
* @j2sNative
*
@@ -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)));
@@ -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);
}
/**
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java
index 8779f3210..9c7f33b9e 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java
@@ -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.
@@ -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);
}
}
}
@@ -1716,6 +1717,9 @@ protected DOMNode setHTMLElementCUI() {
}
}
isTainted = false;
+
+ if (embeddingNode != null)
+ DOMNode.appendChildSafely(embeddingNode, outerNode);
return outerNode;
}
@@ -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);
}
}
}
@@ -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;
}
@@ -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;
}
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSFrameUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSFrameUI.java
index 13e562e1a..3730fe860 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSFrameUI.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSFrameUI.java
@@ -17,6 +17,33 @@
import javajs.api.JSFunction;
import swingjs.api.js.DOMNode;
+/**
+ * New! Frame, JFrame, and JInternalFrame embedding on a web page:
+ *
+ * 1) In the constructor, set the frame to be undecorated:
+ *
+ *
+ * this.setUndecorated(true);
+ *
+ * 2) In the constructor, give the frame a name of your choice
+ *
+ * this.setName("myframe");
+ *
+ *
+ * 3) On the web page somewhere, create a div with id (name + "-div")
+ * and styles position:absolute, left, and right. If you wish, you can
+ * set the width and height, but that is optional. All four of these
+ * values override whatever is given in the constructor.
+ *
+ * <div id="myframe-div"
+style="position:absolute;left:100px;top:200px;width:400px;height:300px"
+></div>
+ *
+ * That's all there is to it! The frame will not be sizable.
+ *
+ * @author hansonr
+ *
+ */
public class JSFrameUI extends JSWindowUI implements FramePeer {
private static final Insets ZERO_INSETS = new Insets(0, 0, 0, 0);
@@ -41,7 +68,6 @@ public class JSFrameUI extends JSWindowUI implements FramePeer {
protected JFrame frame;
// private String title;
private int state;
-// private boolean resizeable;
private DOMNode closerWrap;
protected boolean isModal;
protected int zModal;
@@ -72,10 +98,9 @@ public DOMNode updateDOMNode() {
// a Windows applet has a sort of fuzzy shadowy border
containerNode = frameNode = domNode = newDOMObject("div", id + "_frame");
if (isDummyFrame) {
- DOMNode.setVisible(domNode, false);
+ DOMNode.setVisible(domNode, false);
return domNode;
}
- DOMNode.setStyles(frameNode, "box-shadow", "0px 0px 10px gray", "box-sizing", "content-box");
setWindowClass();
int w = c.getWidth();
int h = c.getHeight();
@@ -85,27 +110,45 @@ public DOMNode updateDOMNode() {
h = defaultHeight;
DOMNode.setSize(frameNode, w, h);
DOMNode.setTopLeftAbsolute(frameNode, 0, 0);
- titleBarNode = newDOMObject("div", id + "_titlebar");
- DOMNode.setTopLeftAbsolute(titleBarNode, 0, 0);
- DOMNode.setStyles(titleBarNode, "background-color", "#E0E0E0", "height", "20px", "font-size", "14px",
- "font-family", "sans-serif", "font-weight", "bold"// ,
- // "border-style", "solid",
- // "border-width", "1px"
- );
-
- titleNode = newDOMObject("label", id + "_title");
- DOMNode.setTopLeftAbsolute(titleNode, 2, 4);
- DOMNode.setStyles(titleNode, "background-color", "#E0E0E0", "height", "20px", "overflow", "hidden");
-
- closerWrap = newDOMObject("div", id + "_closerwrap");
- DOMNode.setTopLeftAbsolute(closerWrap, 0, 0);
- DOMNode.setStyles(closerWrap, "text-align", "right");
-
+ if (frame.getName() != null) {
+ DOMNode node = DOMNode.getElement(frame.getName() + "-div");
+ if (node != null) {
+ frame.setUndecorated(true);
+ frame.setLocation(0, 0);
+ embeddingNode = node;
+ int ew = DOMNode.getWidth(node);
+ int eh = DOMNode.getHeight(node);
+ if (ew > 0 && eh > 0) {
+ frame._freezeBounds(ew, eh);
+ }
+ }
+ }
if (!frame.isUndecorated()) {
+ DOMNode.setStyles(frameNode, "box-shadow", "0px 0px 10px gray", "box-sizing", "content-box");
+ titleBarNode = newDOMObject("div", id + "_titlebar");
+ DOMNode.setTopLeftAbsolute(titleBarNode, 0, 0);
+ DOMNode.setStyles(titleBarNode, "background-color", "#E0E0E0", "height", "20px", "font-size", "14px",
+ "font-family", "sans-serif", "font-weight", "bold"// ,
+ // "border-style", "solid",
+ // "border-width", "1px"
+ );
+
+ titleNode = newDOMObject("label", id + "_title");
+ DOMNode.setTopLeftAbsolute(titleNode, 2, 4);
+ DOMNode.setStyles(titleNode, "background-color", "#E0E0E0", "height", "20px", "overflow", "hidden");
+
+ closerWrap = newDOMObject("div", id + "_closerwrap");
+ DOMNode.setTopLeftAbsolute(closerWrap, 0, 0);
+ DOMNode.setStyles(closerWrap, "text-align", "right");
+
closerNode = newDOMObject("label", id + "_closer", "innerHTML", "X");
DOMNode.setStyles(closerNode, "width", "20px", "height", "20px", "position", "absolute", "text-align",
"center", "right", "0px");
frameNode.appendChild(titleBarNode);
+ titleBarNode.appendChild(titleNode);
+ titleBarNode.appendChild(closerWrap);
+ closerWrap.appendChild(closerNode);
+ DOMNode.setStyles(closerNode, "background-color", "#DDD");// strColor);
}
bindWindowEvents();
if (isModal) {
@@ -115,33 +158,29 @@ public DOMNode updateDOMNode() {
DOMNode.setTopLeftAbsolute(modalNode, 0, 0);
DOMNode.setSize(modalNode, screen.width, screen.height);
}
- setDraggableEvents();
- titleBarNode.appendChild(titleNode);
- titleBarNode.appendChild(closerWrap);
- closerWrap.appendChild(closerNode);
Insets s = getInsets();
DOMNode.setTopLeftAbsolute(frameNode, 0, 0);
DOMNode.setAttrs(frameNode, "width", "" + frame.getWidth() + s.left + s.right, "height",
"" + frame.getHeight() + s.top + s.bottom);
-
+
addFocusHandler();
}
String strColor = toCSSString(c.getBackground());
DOMNode.setStyles(domNode, "background-color", strColor);
- DOMNode.setStyles(frameNode, "background", "#DDD");//strColor);
+ DOMNode.setStyles(frameNode, "background", "#DDD");// strColor);
DOMNode.setStyles(frameNode, "color", toCSSString(c.getForeground()));
- DOMNode.setStyles(closerNode, "background-color", "#DDD");//strColor);
setInnerComponentBounds(width, height);
setTitle(frame.getTitle());
if (!isDummyFrame) {
- DOMNode.setVisible(domNode, jc.isVisible());
-
+ DOMNode.setVisible(domNode, jc.isVisible());
}
return domNode;
}
@Override
protected void setDraggableEvents() {
+ if (embeddingNode != null || frame.isUndecorated())
+ return;
@SuppressWarnings("unused")
DOMNode fnode = frameNode;
JSFunction fGetFrameParent = null;
@@ -289,7 +328,6 @@ public void setMenuBar(Object mb) {
@Override
public void setResizable(boolean resizeable) {
-// this.resizeable = resizeable;
}
@Override
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSInternalFrameUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSInternalFrameUI.java
index 4ff333d0a..48705e425 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSInternalFrameUI.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSInternalFrameUI.java
@@ -35,14 +35,6 @@ public JSInternalFrameUI() {
}
- @Override
- public DOMNode updateDOMNode() {
- super.updateDOMNode();
-
- return domNode;
-
- }
-
@Override
protected void frameCloserAction() {
JInternalFrame jif = (JInternalFrame) iframe;
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSScrollPaneUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSScrollPaneUI.java
index 6f09cbd1f..081f64b40 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSScrollPaneUI.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSScrollPaneUI.java
@@ -55,13 +55,15 @@ public class JSScrollPaneUI extends JSLightweightUI implements
private JSScrollBarUI horizBarUI;
private JSScrollBarUI vertBarUI;
+ @SuppressWarnings("unused")
@Override
public DOMNode updateDOMNode() {
scrollpane = (JScrollPane) jc;
isContainer = true;
if (domNode == null) {
domNode = newDOMObject("div", id);
- DOMNode.setStyles(domNode, "border", "solid black 1px", "box-sizing", "border-box");
+ if (scrolledComponent != null && (/** @j2sNative this.scrolledComponent.isAWT$ || */false))
+ DOMNode.setStyles(domNode, "border", "solid black 1px", "box-sizing", "border-box");
}
// add code here for adjustments when changes in bounds or other properties
// occur.
diff --git a/sources/net.sf.j2s.java.core/src/test/Test_Event.java b/sources/net.sf.j2s.java.core/src/test/Test_Event.java
index 145494c4d..d54a5f1d8 100644
--- a/sources/net.sf.j2s.java.core/src/test/Test_Event.java
+++ b/sources/net.sf.j2s.java.core/src/test/Test_Event.java
@@ -117,7 +117,6 @@ public void eventDispatched(AWTEvent event) {
setLogging();
- this.setName("Test_Event_Frame");
setTitle("testing editor");
setLocation(100, 100);
@@ -141,10 +140,10 @@ public void eventDispatched(AWTEvent event) {
// this next allows floating frames outside the JDesktopPane in SwingJS
getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
- d.setPreferredSize(new Dimension(800, 600));
+ d.setPreferredSize(new Dimension(800, 1));
JInternalFrame main = new JInternalFrame();
-
+ main.setName("main-frame");
main.setContentPane(new JPanel() {
});
@@ -207,16 +206,16 @@ public void mouseExited(MouseEvent e) {
main.setVisible(true);
d.add(main);
- JInternalFrame main2 = new JInternalFrame();
- JPanel p = new JPanel();
- p.setPreferredSize(new Dimension(100, 300));
- p.setMinimumSize(new Dimension(100, 300));
-
- main2.add(p);
- main2.setTitle("main2");
- main2.pack();
- main2.setVisible(true);
- d.add(main2);
+// JInternalFrame main2 = new JInternalFrame();
+// JPanel p = new JPanel();
+// p.setPreferredSize(new Dimension(100, 300));
+// p.setMinimumSize(new Dimension(100, 300));
+//
+// main2.add(p);
+// main2.setTitle("main2");
+// main2.pack();
+// main2.setVisible(true);
+// d.add(main2);
add(d);
pack();
@@ -232,7 +231,7 @@ public void mouseExited(MouseEvent e) {
setVisible(true);
}
- showFocusTimer();
+ //showFocusTimer();
}
private void showFocusTimer() {
diff --git a/sources/net.sf.j2s.java.core/srcjs/js/SwingJSApplet.js b/sources/net.sf.j2s.java.core/srcjs/js/SwingJSApplet.js
index 019b3bf50..342bc3f7f 100644
--- a/sources/net.sf.j2s.java.core/srcjs/js/SwingJSApplet.js
+++ b/sources/net.sf.j2s.java.core/srcjs/js/SwingJSApplet.js
@@ -231,13 +231,13 @@ if (typeof(SwingJS) == "undefined") {
}
proto._addCoreFiles = function() {
- if (this.__Info.core != "NONE" && this.__Info.core != "none")
+ if (this.__Info.core != "NONE" && this.__Info.core != "none" && !J2S._debugCode)
J2S._addCoreFile((this.__Info.core || "swingjs"), this._j2sPath, this.__Info.preloadCore);
- if (J2S._debugCode) {
- // no min package for that
- J2S._addExec([this, null, "swingjs.JSAppletViewer", "load " + this.__Info.code]);
-
- }
+// if (J2S._debugCode) {
+// // no min package for that
+// J2S._addExec([this, null, "swingjs.JSAppletViewer", "load " + this.__Info.code]);
+//
+// }
}
proto._create = function(id, Info){
diff --git a/sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js b/sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js
index c9b557000..6f8b10bdf 100644
--- a/sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js
+++ b/sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js
@@ -5538,16 +5538,15 @@ var newMethodNotFoundException = function (clazz, method) {
//Clazz._Loader.loadZJar(Clazz._Loader.getJ2SLibBase() + "core/coreswingjs.z.js", "swingjs.JSUtil");
//if (!J2S._isAsync) {
- if (!Clazz._loadcore || J2S._coreFiles.length == 0) {
+if (!Clazz._loadcore || J2S._coreFiles.length == 0) {
if (!Clazz._quiet)System.out.println("Clazz: No core files to load -- check Info.core");
- }
-
+} else {
J2S.onClazzLoaded && J2S.onClazzLoaded(1, "Clazz loaded; loading J2S._coreFiles " + J2S._coreFiles.length);
for (var i = 0; i < J2S._coreFiles.length; i++) {
Clazz.loadScript(J2S._coreFiles[i]);
}
J2S.onClazzLoaded && J2S.onClazzLoaded(2, "Clazz loaded; core files loaded");
-
+}
})(Clazz, J2S);
}; // called by external application
diff --git a/sources/net.sf.j2s.java.core/srcjs/swingjs2.js b/sources/net.sf.j2s.java.core/srcjs/swingjs2.js
index 8deb7dff3..977b1c6ab 100644
--- a/sources/net.sf.j2s.java.core/srcjs/swingjs2.js
+++ b/sources/net.sf.j2s.java.core/srcjs/swingjs2.js
@@ -19179,16 +19179,15 @@ var newMethodNotFoundException = function (clazz, method) {
//Clazz._Loader.loadZJar(Clazz._Loader.getJ2SLibBase() + "core/coreswingjs.z.js", "swingjs.JSUtil");
//if (!J2S._isAsync) {
- if (!Clazz._loadcore || J2S._coreFiles.length == 0) {
+if (!Clazz._loadcore || J2S._coreFiles.length == 0) {
if (!Clazz._quiet)System.out.println("Clazz: No core files to load -- check Info.core");
- }
-
+} else {
J2S.onClazzLoaded && J2S.onClazzLoaded(1, "Clazz loaded; loading J2S._coreFiles " + J2S._coreFiles.length);
for (var i = 0; i < J2S._coreFiles.length; i++) {
Clazz.loadScript(J2S._coreFiles[i]);
}
J2S.onClazzLoaded && J2S.onClazzLoaded(2, "Clazz loaded; core files loaded");
-
+}
})(Clazz, J2S);
}; // called by external application
@@ -19426,13 +19425,13 @@ if (typeof(SwingJS) == "undefined") {
}
proto._addCoreFiles = function() {
- if (this.__Info.core != "NONE" && this.__Info.core != "none")
+ if (this.__Info.core != "NONE" && this.__Info.core != "none" && !J2S._debugCode)
J2S._addCoreFile((this.__Info.core || "swingjs"), this._j2sPath, this.__Info.preloadCore);
- if (J2S._debugCode) {
- // no min package for that
- J2S._addExec([this, null, "swingjs.JSAppletViewer", "load " + this.__Info.code]);
-
- }
+// if (J2S._debugCode) {
+// // no min package for that
+// J2S._addExec([this, null, "swingjs.JSAppletViewer", "load " + this.__Info.code]);
+//
+// }
}
proto._create = function(id, Info){