diff --git a/sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip b/sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip index f6fdabe80..9526ffb00 100644 Binary files a/sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip and b/sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip differ diff --git a/sources/net.sf.j2s.core/dist/swingjs/timestamp b/sources/net.sf.j2s.core/dist/swingjs/timestamp index 92a16155d..9cf6b0119 100644 --- a/sources/net.sf.j2s.core/dist/swingjs/timestamp +++ b/sources/net.sf.j2s.core/dist/swingjs/timestamp @@ -1 +1 @@ -20210728172208 +20211009053211 diff --git a/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/SwingJS-site.zip b/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/SwingJS-site.zip index f6fdabe80..9526ffb00 100644 Binary files a/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/SwingJS-site.zip and b/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/SwingJS-site.zip differ diff --git a/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/timestamp b/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/timestamp index 92a16155d..9cf6b0119 100644 --- a/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/timestamp +++ b/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/timestamp @@ -1 +1 @@ -20210728172208 +20211009053211 diff --git a/sources/net.sf.j2s.java.core/dist/SwingJS-site.zip b/sources/net.sf.j2s.java.core/dist/SwingJS-site.zip index f6fdabe80..9526ffb00 100644 Binary files a/sources/net.sf.j2s.java.core/dist/SwingJS-site.zip and b/sources/net.sf.j2s.java.core/dist/SwingJS-site.zip differ diff --git a/sources/net.sf.j2s.java.core/src/java/awt/Container.java b/sources/net.sf.j2s.java.core/src/java/awt/Container.java index 7cf6052a5..a7850bc07 100644 --- a/sources/net.sf.j2s.java.core/src/java/awt/Container.java +++ b/sources/net.sf.j2s.java.core/src/java/awt/Container.java @@ -45,6 +45,7 @@ import java.util.EventListener; import java.util.Set; +import javax.swing.JApplet; import javax.swing.JInternalFrame; import javajs.util.Lst; @@ -1087,6 +1088,10 @@ protected void addImplCont(Component comp, Object constraints, int index) { comp.background = comp.foreground = null; // this parent should not set the background color } // SwingJS used for all add methods + // When adding an applet, we should just add its content pane + if (comp instanceof JApplet) { + comp = ((JApplet)comp).getLayeredPane(); + } /* * Check for correct arguments: index in bounds, comp cannot be one of this diff --git a/sources/net.sf.j2s.java.core/src/java/awt/Font.java b/sources/net.sf.j2s.java.core/src/java/awt/Font.java index ddf286eec..e6d65331c 100644 --- a/sources/net.sf.j2s.java.core/src/java/awt/Font.java +++ b/sources/net.sf.j2s.java.core/src/java/awt/Font.java @@ -1977,7 +1977,7 @@ public Font deriveFont(float sizePts) { return f; } AttributeValues newValues = getAttributeValues().clone(); - newValues.setSize(size); + newValues.setSize(sizePts); return new Font(newValues, null, -1, createdFont, font2DHandle); } diff --git a/sources/net.sf.j2s.java.core/src/java/awt/Window.java b/sources/net.sf.j2s.java.core/src/java/awt/Window.java index 4bccb63f0..0a1eca9bb 100644 --- a/sources/net.sf.j2s.java.core/src/java/awt/Window.java +++ b/sources/net.sf.j2s.java.core/src/java/awt/Window.java @@ -386,7 +386,7 @@ public void setTrayIconWindow(boolean isTrayIconWindow) { // // private static final Logger log = Logger.getLogger("java.awt.Window"); -// private static final boolean locationByPlatformProp; + private static final boolean locationByPlatformProp = false; transient boolean isTrayIconWindow = false; @@ -536,7 +536,8 @@ public Window(Window owner) { public Window(Window owner, GraphicsConfiguration gc) { super(); 秘winOrApplet = true; - 秘paintClass = 秘updateClass = /**@j2sNative C$ || */null; + 秘paintClass = 秘updateClass = /** @j2sNative C$ || */ + null; setAppContext(); parent = owner; if (owner != null) @@ -567,16 +568,15 @@ public Window(Window owner, GraphicsConfiguration gc) { /* offset the initial location with the original of the screen */ /* and any insets */ - // SwingJS TODO ?? - // Rectangle screenBounds = graphicsConfig.getBounds(); - // Insets screenInsets = getToolkit().getScreenInsets(graphicsConfig); - // int x = getX() + screenBounds.x + screenInsets.left; - // int y = getY() + screenBounds.y + screenInsets.top; - // if (x != this.x || y != this.y) { - // setLocation(x, y); - // /* reset after setLocation */ - // // setLocationByPlatform(locationByPlatformProp); - // } + Rectangle screenBounds = getGraphicsConfiguration().getBounds(); + Insets screenInsets = getToolkit().getScreenInsets(graphicsConfig); + int x = getX() + screenBounds.x + screenInsets.left; + int y = getY() + screenBounds.y + screenInsets.top; + if (x != ((Container) this).x || y != ((Container) this).y) { + setLocation(x, y); + /* reset after setLocation */ + setLocationByPlatform(locationByPlatformProp); + } modalExclusionType = ModalExclusionType.NO_EXCLUDE; @@ -3159,80 +3159,80 @@ protected boolean canContainFocusOwner(Component focusOwnerCandidate) { return super.canContainFocusOwner(focusOwnerCandidate) && isFocusableWindow(); } -// private boolean locationByPlatform = locationByPlatformProp; - -// /** -// * Sets whether this Window should appear at the default location for the -// * native windowing system or at the current location (returned by -// * getLocation) the next time the Window is made visible. -// * This behavior resembles a native window shown without programmatically -// * setting its location. Most windowing systems cascade windows if their -// * locations are not explicitly set. The actual location is determined once the -// * window is shown on the screen. -// *

-// * This behavior can also be enabled by setting the System Property -// * "java.awt.Window.locationByPlatform" to "true", though calls to this method -// * take precedence. -// *

-// * Calls to setVisible, setLocation and -// * setBounds after calling setLocationByPlatform clear -// * this property of the Window. -// *

-// * For example, after the following code is executed: -// *

-// * setLocationByPlatform(true); -// * setVisible(true); -// * boolean flag = isLocationByPlatform(); -// *
-// * The window will be shown at platform's default location and -// * flag will be false. -// *

-// * In the following sample: -// *

-// * setLocationByPlatform(true); -// * setLocation(10, 10); -// * boolean flag = isLocationByPlatform(); -// * setVisible(true); -// *
-// * The window will be shown at (10, 10) and flag will be -// * false. -// * -// * @param locationByPlatform true if this Window should appear -// * at the default location, false if at the current location -// * @throws IllegalComponentStateException if the window -// * is showing on screen and locationByPlatform is true. -// * @see #setLocation -// * @see #isShowing -// * @see #setVisible -// * @see #isLocationByPlatform -// * @see java.lang.System#getProperty(String) -// * @since 1.5 -// */ -// public void setLocationByPlatform(boolean locationByPlatform) { + private boolean locationByPlatform = locationByPlatformProp; + + /** + * Sets whether this Window should appear at the default location for the + * native windowing system or at the current location (returned by + * getLocation) the next time the Window is made visible. + * This behavior resembles a native window shown without programmatically + * setting its location. Most windowing systems cascade windows if their + * locations are not explicitly set. The actual location is determined once the + * window is shown on the screen. + *

+ * This behavior can also be enabled by setting the System Property + * "java.awt.Window.locationByPlatform" to "true", though calls to this method + * take precedence. + *

+ * Calls to setVisible, setLocation and + * setBounds after calling setLocationByPlatform clear + * this property of the Window. + *

+ * For example, after the following code is executed: + *

+ * setLocationByPlatform(true); + * setVisible(true); + * boolean flag = isLocationByPlatform(); + *
+ * The window will be shown at platform's default location and + * flag will be false. + *

+ * In the following sample: + *

+ * setLocationByPlatform(true); + * setLocation(10, 10); + * boolean flag = isLocationByPlatform(); + * setVisible(true); + *
+ * The window will be shown at (10, 10) and flag will be + * false. + * + * @param locationByPlatform true if this Window should appear + * at the default location, false if at the current location + * @throws IllegalComponentStateException if the window + * is showing on screen and locationByPlatform is true. + * @see #setLocation + * @see #isShowing + * @see #setVisible + * @see #isLocationByPlatform + * @see java.lang.System#getProperty(String) + * @since 1.5 + */ + public void setLocationByPlatform(boolean locationByPlatform) { + synchronized (getTreeLock()) { + if (locationByPlatform && isShowing()) { + throw new IllegalComponentStateException("The window is showing on screen."); + } + this.locationByPlatform = locationByPlatform; + } + } + + /** + * Returns true if this Window will appear at the default location + * for the native windowing system the next time this Window is made visible. + * This method always returns false if the Window is showing on the + * screen. + * + * @return whether this Window will appear at the default location + * @see #setLocationByPlatform + * @see #isShowing + * @since 1.5 + */ + public boolean isLocationByPlatform() { // synchronized (getTreeLock()) { -// if (locationByPlatform && isShowing()) { -// throw new IllegalComponentStateException("The window is showing on screen."); -// } -// this.locationByPlatform = locationByPlatform; -// } -// } - -// /** -// * Returns true if this Window will appear at the default location -// * for the native windowing system the next time this Window is made visible. -// * This method always returns false if the Window is showing on the -// * screen. -// * -// * @return whether this Window will appear at the default location -// * @see #setLocationByPlatform -// * @see #isShowing -// * @since 1.5 -// */ -// public boolean isLocationByPlatform() { -// synchronized (getTreeLock()) { -// return locationByPlatform; -// } -// } + return locationByPlatform; +// } + } /** * {@inheritDoc} diff --git a/sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java b/sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java index 54f7c548b..25013de75 100644 --- a/sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java +++ b/sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java @@ -913,6 +913,7 @@ public ColorModel getColorModel() { * @return the WriteableRaster of this BufferedImage . */ public WritableRaster getRaster() { + // ok, but raster.getDataBuffer().getData() is going to require a flush(); return raster; } diff --git a/sources/net.sf.j2s.java.core/src/javajs/async/Assets.java b/sources/net.sf.j2s.java.core/src/javajs/async/Assets.java index 1db313fc4..bd7a38fc7 100644 --- a/sources/net.sf.j2s.java.core/src/javajs/async/Assets.java +++ b/sources/net.sf.j2s.java.core/src/javajs/async/Assets.java @@ -406,12 +406,11 @@ private static InputStream getAssetStream(String path, boolean zipOnly) { if (url == null && !zipOnly) { url = Assets.class.getClassLoader().getResource(path); } - InputStream is = null; try { - is = url.openStream(); + return (url == null ? null : url.openStream()); } catch (Throwable t) { } - return is; + return null; } /** * Determine the path to an asset. If not found in a zip file asset, return the diff --git a/sources/net.sf.j2s.java.core/src/javajs/async/AsyncDialog.java b/sources/net.sf.j2s.java.core/src/javajs/async/AsyncDialog.java index 5c5d114b3..2cfa66e48 100644 --- a/sources/net.sf.j2s.java.core/src/javajs/async/AsyncDialog.java +++ b/sources/net.sf.j2s.java.core/src/javajs/async/AsyncDialog.java @@ -106,8 +106,12 @@ public void showMessageDialog(Component frame, Object message, ActionListener a) } public void showMessageDialog(Component frame, Object message, String title, ActionListener a) { + showMessageDialog(frame, message, title, JOptionPane.INFORMATION_MESSAGE, a); + } + + public void showMessageDialog(Component frame, Object message, String title, int messageType, ActionListener a) { setListener(a); - JOptionPane.showMessageDialog(frame, message, title, JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(frame, message, title, messageType); unsetListener(); if (/** @j2sNative false || */true) process("" + message); diff --git a/sources/net.sf.j2s.java.core/src/javajs/async/AsyncSwingWorker.java b/sources/net.sf.j2s.java.core/src/javajs/async/AsyncSwingWorker.java index 2d3c8ade1..628d05a4b 100644 --- a/sources/net.sf.j2s.java.core/src/javajs/async/AsyncSwingWorker.java +++ b/sources/net.sf.j2s.java.core/src/javajs/async/AsyncSwingWorker.java @@ -223,11 +223,13 @@ public void setNote(String note) { } /** - * Cancel the asynchronous process. + * Cancel the asynchronous process. This will fire the PROPERTY_STATE property + * change with value CANCELED_ASYNC * */ public void cancelAsync() { helper.interrupt(); + firePropertyChange(PROPERTY_STATE, null, CANCELED_ASYNC); } /** @@ -348,7 +350,7 @@ public boolean stateLoop() { case STATE_LOOP: if (checkCanceled()) { helper.setState(STATE_DONE); - firePropertyChange(PROPERTY_STATE, null, CANCELED_ASYNC); + cancelAsync(); } else { int ret = doInBackgroundAsync(progressAsync); if (!helper.isAlive() || isPaused) { diff --git a/sources/net.sf.j2s.java.core/src/javajs/util/DF.java b/sources/net.sf.j2s.java.core/src/javajs/util/DF.java index aee013062..1a4b1fb72 100644 --- a/sources/net.sf.j2s.java.core/src/javajs/util/DF.java +++ b/sources/net.sf.j2s.java.core/src/javajs/util/DF.java @@ -67,6 +67,9 @@ public static String formatDecimal(float value, int decimalDigits) { if (decimalDigits == Integer.MAX_VALUE || value == Float.NEGATIVE_INFINITY || value == Float.POSITIVE_INFINITY || Float.isNaN(value)) return "" + value; + boolean isNeg = (value < 0); + if (isNeg) + value = -value; int n; if (decimalDigits < 0) { decimalDigits = -decimalDigits; @@ -78,28 +81,27 @@ public static String formatDecimal(float value, int decimalDigits) { n = 0; double d; if (Math.abs(value) < 1) { - n = 10; - d = value * 1e-10; + n = 100; + d = value * 1e-100; } else { - n = -10; - d = value * 1e10; + n = -100; + d = value * 1e100; } String s = ("" + d).toUpperCase(); - int i = s.indexOf("E"); - n = PT.parseInt(s.substring(i + 1)) + n; + int i1 = s.indexOf("E"); String sf; - if (i < 0) { + if (i1 < 0) { sf = "" + value; } else { - float f = PT.parseFloat(s.substring(0, i)); - if (f == 10 || f == -10) { - //d = 9.99999997465; n = -6 --> 10.00000E-5 - f /= 10; - n += (n < 0 ? 1 : -1); - } + n = PT.parseInt(s.substring(i1 + (s.indexOf("E+") == i1 ? 2 : 1))) + n; + float f = PT.parseFloat(s.substring(0, i1)); sf = formatDecimal(f, decimalDigits - 1); + if (sf.startsWith("10.")) { + sf = formatDecimal(1, decimalDigits - 1); + n++; + } } - return sf + "E" + (n >= 0 ? "+" : "") + n; + return (isNeg ? "-" : "") + sf + "E" + (n >= 0 ? "+" : "") + n; } if (decimalDigits >= formattingStrings.length) @@ -108,11 +110,6 @@ public static String formatDecimal(float value, int decimalDigits) { int pt = s1.indexOf("."); if (pt < 0) // specifically JavaScript "-2" not "-2.0" return s1 + formattingStrings[decimalDigits].substring(1); - boolean isNeg = s1.startsWith("-"); - if (isNeg) { - s1 = s1.substring(1); - pt--; - } int pt1 = s1.indexOf("E-"); if (pt1 > 0) { n = PT.parseInt(s1.substring(pt1 + 1)); @@ -140,7 +137,8 @@ public static String formatDecimal(float value, int decimalDigits) { int pt2 = decimalDigits + pt + 1; if (pt2 < len && s1.charAt(pt2) >= '5') { return formatDecimal( - value + (isNeg ? -1 : 1) * formatAdds[decimalDigits], decimalDigits); + (isNeg ? -1 : 1) * (value + formatAdds[decimalDigits]), + decimalDigits); } String s0 = s1.substring(0, (decimalDigits == 0 ? pt diff --git a/sources/net.sf.j2s.java.core/src/javajs/util/M4.java b/sources/net.sf.j2s.java.core/src/javajs/util/M4.java index 58bd3553e..ed162b7c0 100644 --- a/sources/net.sf.j2s.java.core/src/javajs/util/M4.java +++ b/sources/net.sf.j2s.java.core/src/javajs/util/M4.java @@ -570,6 +570,17 @@ public void sub(M4 m1) { m32 -= m1.m32; m33 -= m1.m33; } + + /** + * add to translation + * + * @param pt + */ + public void add(T3 pt) { + m03 += pt.x; + m13 += pt.y; + m23 += pt.z; + } /** * Sets the value of this matrix to its transpose. diff --git a/sources/net.sf.j2s.java.core/src/javajs/util/P3.java b/sources/net.sf.j2s.java.core/src/javajs/util/P3.java index 1e1dfdbbf..6052ea0df 100644 --- a/sources/net.sf.j2s.java.core/src/javajs/util/P3.java +++ b/sources/net.sf.j2s.java.core/src/javajs/util/P3.java @@ -58,5 +58,9 @@ public static P3 new3(float x, float y, float z) { p.z = z; return p; } + + public static P3 newA(float[] a) { + return new3(a[0], a[1], a[2]); + } } diff --git a/sources/net.sf.j2s.java.core/src/javax/swing/JMenu.java b/sources/net.sf.j2s.java.core/src/javax/swing/JMenu.java index 4a40df26b..5e411173f 100644 --- a/sources/net.sf.j2s.java.core/src/javax/swing/JMenu.java +++ b/sources/net.sf.j2s.java.core/src/javax/swing/JMenu.java @@ -337,7 +337,7 @@ public void setPopupMenuVisible(boolean b) { // System.out.println("in JMenu.setPopupMenuVisible " + b); // // Thread.dumpStack(); // } - if (!isEnabled()) + if (!isEnabled() || popupMenu == null) return; if (b && popupMenu.getPeer() == null) popupMenu.addNotify();// BH SwingJS diff --git a/sources/net.sf.j2s.java.core/src/javax/swing/JOptionPane.java b/sources/net.sf.j2s.java.core/src/javax/swing/JOptionPane.java index 10551970c..43091d9ee 100644 --- a/sources/net.sf.j2s.java.core/src/javax/swing/JOptionPane.java +++ b/sources/net.sf.j2s.java.core/src/javax/swing/JOptionPane.java @@ -729,26 +729,23 @@ public static void showMessageDialog(Component parentComponent, Object message, /** * Brings up a dialog displaying a message, specifying all parameters. * - * @param parentComponent - * determines the Frame in which the dialog is - * displayed; if null, or if the - * parentComponent has no Frame, a - * default Frame is used - * @param message - * the Object to display - * @param title - * the title string for the dialog - * @param messageType - * the type of message to be displayed: - * ERROR_MESSAGE, INFORMATION_MESSAGE, - * WARNING_MESSAGE, QUESTION_MESSAGE, - * or PLAIN_MESSAGE - * @param icon - * an icon to display in the dialog that helps the user identify - * the kind of message that is being displayed - * @exception HeadlessException - * if GraphicsEnvironment.isHeadless returns - * true + * @param parentComponent determines the Frame in which the dialog + * is displayed; if null, or if the + * parentComponent has no + * Frame, a default Frame is + * used + * @param message the Object to display + * @param title the title string for the dialog + * @param messageType the type of message to be displayed: + * ERROR_MESSAGE, + * INFORMATION_MESSAGE, + * WARNING_MESSAGE, + * QUESTION_MESSAGE, or + * PLAIN_MESSAGE + * @param icon an icon to display in the dialog that helps the user + * identify the kind of message that is being displayed + * @exception HeadlessException if GraphicsEnvironment.isHeadless + * returns true * @see java.awt.GraphicsEnvironment#isHeadless */ public static void showMessageDialog(Component parentComponent, Object message, String title, int messageType, @@ -757,13 +754,15 @@ public static void showMessageDialog(Component parentComponent, Object message, boolean simplify = USE_HTML5_MODAL_FOR_WARNINGS_AND_ERRORS && (messageType == WARNING_MESSAGE || messageType == ERROR_MESSAGE); - if (simplify || !isListener(parentComponent)) { - if (!simplify && !(message instanceof String)) - warnJSDeveloper(); - String s = getMessageTypeString(messageType, ": ") + (title == "Message" ? "" : title + "\n\n") - + (message instanceof String ? "" + message : "?"); - JSUtil.alert(s); - return; + boolean haveListener = isListener(parentComponent); + if (simplify || !haveListener) { + if (message instanceof String) { + String s = getMessageTypeString(messageType, ": ") + (title == "Message" ? "" : title + "\n\n") + + (message instanceof String ? "" + message : "?"); + JSUtil.alert(s); + return; + } + warnJSDeveloper(); } showOptionDialog(parentComponent, message, title, DEFAULT_OPTION, messageType, icon, null, null); } diff --git a/sources/net.sf.j2s.java.core/src/swingjs/api/js/HTML5Video.java b/sources/net.sf.j2s.java.core/src/swingjs/api/js/HTML5Video.java index 81b30a9ef..b10c08bff 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/api/js/HTML5Video.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/api/js/HTML5Video.java @@ -253,7 +253,7 @@ public Void apply(Object jsevent) { * Remove action listener * * @param jsvideo the HTML5 video element - * @param listeners an array of event/listener pairs created by + * @param listeners an array of event/listener epairs created by * addActionListener */ public static void removeActionListener(HTML5Video jsvideo, Object[] listeners) { @@ -261,6 +261,7 @@ public static void removeActionListener(HTML5Video jsvideo, Object[] listeners) for (int i = 0; i < eventTypes.length; i++) { jsvideo.removeEventListener(eventTypes[i]); } + return; } for (int i = 0; i < listeners.length; i += 2) { @@ -314,6 +315,11 @@ public static JLabel createLabel(Object source) { */ public static JDialog createDialog(Frame parent, Object source, int maxWidth, Function whenReady) { + return createDialog(parent, source, maxWidth, true, whenReady); + } + + public static JDialog createDialog(Frame parent, Object source, int maxWidth, boolean addControls, + Function whenReady) { JDialog dialog = new JDialog(parent); Container p = dialog.getContentPane(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); @@ -322,7 +328,8 @@ public static JDialog createDialog(Frame parent, Object source, int maxWidth, // not in Java! dialog.putClientProperty("jsvideo", label); p.add(label); label.setVisible(false); - p.add(getControls(label)); + if (addControls) + p.add(getControls(label)); dialog.setModal(false); dialog.pack(); dialog.setVisible(true); diff --git a/sources/net.sf.j2s.java.core/src/swingjs/jquery/j2sComboBox.js b/sources/net.sf.j2s.java.core/src/swingjs/jquery/j2sComboBox.js index 0c638a55b..54e8ec788 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/jquery/j2sComboBox.js +++ b/sources/net.sf.j2s.java.core/src/swingjs/jquery/j2sComboBox.js @@ -17,13 +17,13 @@ J2S.__makeComboBox = function() { $( function() { $('head').append('' + +'\n.j2scblist {background-color:inherit;position:absolute; left:0px;top:0px;margin:0;border:black solid 1px;cursor:pointer;text-align:left;padding:0em;scrollbar-width:thin;cursor:pointer;}' ); var CLOSE_DELAY = 100; // BH 2019.10.04 50 was just a bit too fast; could close early @@ -40,7 +40,7 @@ J2S.__makeComboBox = function() { disabled: false, popupVisible: false, selectedIndex: -1, - backgroundColor: "white", + backgroundColor: "blue", // z-index zIndex:999999, name:null, @@ -185,10 +185,14 @@ J2S.__makeComboBox = function() { }, updateCSS: function() { var cbox = this.cont.parent(); + var bg = cbox.css("background-color"); + this.options.backgroundColor = bg; var font = {"font-family": cbox.css("font-family") , "font-size": cbox.css("font-size") , "font-weight": cbox.css("font-weight") , "font-style": cbox.css("font-style") + , "font-style": cbox.css("font-style") + , backgroundColor: bg }; var w = this.element.width(); if (w == 0) @@ -197,23 +201,23 @@ J2S.__makeComboBox = function() { this.cont.css({ width: (w - 2) + 'px', height: h, - backgroundColor: this.options.backgroundColor + backgroundColor: bg }); this.head.css({ width: (w - 20) + 'px', - height: h, - backgroundColor: this.options.backgroundColor + height: h }); this.head.css(font); this.btn.css({ left: (w - 20) + 'px', - height: h + height: h, + backgroundColor: bg }); h = (this.options.height ? this.options.height + 'px' : null); this.popup.css({ width: w + 'px', height: h - }); + }); this.popup.css(font); this.list.css({ width: w + 'px', diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/ButtonListener.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/ButtonListener.java index 580fdd7df..bdcde3afb 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/ButtonListener.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/ButtonListener.java @@ -132,6 +132,9 @@ public void propertyChange(PropertyChangeEvent e) { } protected void checkOpacity(AbstractButton b) { + if (!b.isContentAreaFilled()) { + DOMNode.setStyles(ui.domNode, "border", "none", "outline", "none"); + } b.setOpaque(b.isContentAreaFilled()); } @@ -297,7 +300,7 @@ public void mouseReleased(MouseEvent e) { return; b.doClick(0); verifyButtonClick(b, true); - JSComponentUI ui = b.秘getUI(); +// JSComponentUI ui = b.秘getUI(); } } diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/HTML5LookAndFeel.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/HTML5LookAndFeel.java index b3f9ac6ff..1df10471b 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/HTML5LookAndFeel.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/HTML5LookAndFeel.java @@ -614,7 +614,7 @@ protected void initComponentDefaults(UIDefaults table) { InsetsUIResource zeroInsets = new InsetsUIResource(0, 0, 0, 0); InsetsUIResource twoInsets = new InsetsUIResource(2, 2, 2, 2); InsetsUIResource threeInsets = new InsetsUIResource(3, 3, 3, 3); - + InsetsUIResource minus2Insets = new InsetsUIResource(0,2,-2,2); // a bit of a hack for JSMenu // // *** Shared Borders Object marginBorder = new SwingLazyValue("javax.swing.plaf.basic.BasicBorders$MarginBorder"); Object etchedBorder = new BorderUIResource.EtchedBorderUIResource(); @@ -1376,7 +1376,7 @@ public Object createValue(UIDefaults table) { "Menu.border", marginBorder, "Menu.borderPainted", Boolean.FALSE, "Menu.margin", - twoInsets, + minus2Insets,//twoInsets, // "Menu.checkIcon", menuItemCheckIcon, // "Menu.arrowIcon", menuArrowIcon, // "Menu.menuPopupOffsetX", new Integer(0), diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSButtonUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSButtonUI.java index 981497704..26f701699 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSButtonUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSButtonUI.java @@ -212,6 +212,8 @@ protected void setupButton() { DOMNode.setStyle(buttonNode, "border", "none"); else if (button.getBorder() == BorderFactory.html5Border) DOMNode.setStyle(buttonNode, "border", null); + if (!button.isContentAreaFilled()) + DOMNode.setStyles(domNode, "border", "none", "outline", "none"); // // System.out.println(button.getText() + " " + button.getBorder()); if (!isMenuSep) { @@ -222,6 +224,26 @@ else if (button.getBorder() == BorderFactory.html5Border) } + @Override + public void dispose() { + if (isUIDisabled) + return; + super.dispose(); + if (menuAnchorNode != null) { + // This is set in j2sMenu.js; we set it null here + // re-establish events when this button is added again + DOMNode.setAttr(menuAnchorNode, "_menu", null); + } + } + + @Override + protected void undisposeUI(DOMNode node) { + if (!isDisposed) + return; + super.undisposeUI(node); + } + + /** * called by j2sApplet.js * diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComboBoxUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComboBoxUI.java index 169d5a295..0ca946dcc 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComboBoxUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComboBoxUI.java @@ -98,10 +98,12 @@ public DOMNode updateDOMNode() { if (domNode == null) { domNode = focusNode = newDOMObject("div", id); setDataShadowKeyComponent(domNode, listBox); + } addFocusHandler(); setCssFont(domNode, c.getFont()); popup.updateEnabled(); + setBackgroundImpl(jc.isOpaque() ? getBackground() : null); return updateDOMNodeCUI(); } @@ -261,7 +263,7 @@ protected void installDefaults() { // NOTE: this needs to default to true if not specified Boolean b = (Boolean) UIManager.get("ComboBox.squareButton"); squareButton = b == null ? true : b; - + padding = UIManager.getInsets("ComboBox.padding"); } @@ -1745,8 +1747,10 @@ public void itemStateChanged(ItemEvent e) { // @Override public void propertyChange(PropertyChangeEvent e) { + Component editor = JSComboBoxUI.this.editor; String propertyName = e.getPropertyName(); - //System.out.println("handler prop " + propertyName); + JSComboPopupList popup = JSComboBoxUI.this.popup; + // System.out.println("handler prop " + propertyName); if (e.getSource() == editor) { // If the border of the editor changes then this can effect // the size of the editor which can cause the combo's size to @@ -1758,7 +1762,8 @@ public void propertyChange(PropertyChangeEvent e) { } } else { JComboBox comboBox = (JComboBox) e.getSource(); - if (propertyName == "model") { + switch (propertyName) { + case "model": ComboBoxModel newModel = (ComboBoxModel) e.getNewValue(); ComboBoxModel oldModel = (ComboBoxModel) e.getOldValue(); @@ -1783,10 +1788,14 @@ public void propertyChange(PropertyChangeEvent e) { popup.updateSelectedIndex(); popup.updateCSS(); repaint(); - } else if (propertyName == "editor" && comboBox.isEditable()) { - addEditor(); - comboBox.revalidate(); - } else if (propertyName == "editable") { + break; + case "editor": + if (comboBox.isEditable()) { + addEditor(); + comboBox.revalidate(); + } + break; + case "editable": if (comboBox.isEditable()) { comboBox.setRequestFocusEnabled(false); addEditor(); @@ -1796,47 +1805,74 @@ public void propertyChange(PropertyChangeEvent e) { } updateToolTipTextForChildren(); comboBox.revalidate(); - } else if (propertyName == "enabled") { + break; + case "enabled": boolean enabled = comboBox.isEnabled(); if (editor != null) editor.setEnabled(enabled); // if (arrowButton != null) // arrowButton.setEnabled(enabled); repaint(); - } else if (propertyName == "focusable") { + break; + case "focusable": boolean focusable = comboBox.isFocusable(); if (editor != null) editor.setFocusable(focusable); // if (arrowButton != null) // arrowButton.setFocusable(focusable); repaint(); - } else if (propertyName == "maximumRowCount") { + break; + case "maximumRowCount": if (isPopupVisible(comboBox)) { setPopupVisible(comboBox, false); setPopupVisible(comboBox, true); } - } else if (propertyName == "font") { + break; + case "background": + Color c = comboBox.getBackground(); + listBox.setBackground(c); + if (editor != null) { + editor.setBackground(c); + } + popup.updateCSS(); + break; + case "foreground": listBox.setFont(comboBox.getFont()); if (editor != null) { editor.setFont(comboBox.getFont()); } isMinimumSizeDirty = true; isDisplaySizeDirty = true; + popup.updateCSS(); + break; + case "font": + listBox.setFont(comboBox.getFont()); + if (editor != null) { + editor.setFont(comboBox.getFont()); + } + isMinimumSizeDirty = true; + isDisplaySizeDirty = true; + popup.updateCSS(); comboBox.validate(); - } else if (propertyName == JComponent.TOOL_TIP_TEXT_KEY) { + break; + case JComponent.TOOL_TIP_TEXT_KEY: updateToolTipTextForChildren(); - } else if (propertyName == JSComboBoxUI.IS_TABLE_CELL_EDITOR) { + break; + case JSComboBoxUI.IS_TABLE_CELL_EDITOR: Boolean inTable = (Boolean) e.getNewValue(); isTableCellEditor = inTable.equals(Boolean.TRUE) ? true : false; - } else if (propertyName == "prototypeDisplayValue") { + break; + case "prototypeDisplayValue": isMinimumSizeDirty = true; isDisplaySizeDirty = true; comboBox.revalidate(); - } else if (propertyName == "renderer") { + break; + case "renderer": isMinimumSizeDirty = true; isDisplaySizeDirty = true; popup.updateList(); comboBox.revalidate(); + break; } } } diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComboPopupList.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComboPopupList.java index 6d9bfa6e7..ff6dd2866 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComboPopupList.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComboPopupList.java @@ -141,8 +141,9 @@ void updateText() { void updateCSS() { DOMNode.setSize(cbui.domNode, cbui.width, cbui.height); - if (j2scb != null) + if (j2scb != null) { j2scb.j2sCB("updateCSS"); + } } void updateList() { 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 8c032d99e..75fcc5098 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 @@ -1795,7 +1795,7 @@ protected Dimension setHTMLSize1(DOMNode node, boolean addCSS, boolean usePrefer w0 = w0i = ""; } } - DOMNode.setStyles(node, "position", null, "width", null, "height", null); + DOMNode.setStyles(node, "position", null, "width", getSizingWidth(), "height", null); if (innerNode != null) // JSListUI only DOMNode.setStyles(innerNode, "width", null, "height", null); // process of discovering width and height is facilitated using @@ -1858,6 +1858,11 @@ protected Dimension setHTMLSize1(DOMNode node, boolean addCSS, boolean usePrefer return dim; } + protected String getSizingWidth() { + return null; + } + + protected Rectangle getBoundingRect(DOMNode node) { if (tempDiv == null) { tempDiv = DOMNode.createElement("div", "_temp"); @@ -3731,7 +3736,11 @@ public void paintBackground(JSGraphics2D g) { if (!paintsSelf) setBackgroundDOM(domNode, color); // preliminary -- DOM only, when the background is set - } else if (allowPaintedBackground && (isOpaque && (isPanel || cellComponent != null || jc.getComponentCount() > 0) || jc.秘g != null)) { + } else if (allowPaintedBackground && (isOpaque && (isPanel + || isLabel && paintsSelf // overridden paintComponent + || cellComponent != null + || jc.getComponentCount() > 0) + || jc.秘g != null)) { // all opaque components must paint their background // just in case they have painted CHILDREN or if they are table cell components if (isOpaque == (color.getAlpha() == 255)) { diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSLayeredPaneUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSLayeredPaneUI.java index f7c6d2ef8..cf243bf7e 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSLayeredPaneUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSLayeredPaneUI.java @@ -1,11 +1,13 @@ package swingjs.plaf; +import java.awt.Dimension; + import javax.swing.JComponent; import swingjs.api.js.DOMNode; -public class JSLayeredPaneUI extends JSLightweightUI { +public class JSLayeredPaneUI extends JSPanelUI { public JSLayeredPaneUI() { isContainer = isLayeredPane = true; @@ -19,6 +21,12 @@ public DOMNode updateDOMNode() { // add code here for adjustments when changes in bounds or other properties occur. return domNode; } + + @Override + protected Dimension getHTMLSizePreferred(DOMNode obj, boolean addCSS) { + return super.getHTMLSizePreferred(obj, addCSS); + } + @Override public void installUI(JComponent jc) { diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuBarUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuBarUI.java index 35d7b552d..d8953dd37 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuBarUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuBarUI.java @@ -133,7 +133,7 @@ public Insets getInsets() { public Dimension getPreferredSize(JComponent jc) { // layout manager will call this specifically for the height // we could make this larger if it ends up being multilevel? - Dimension d = new Dimension(0, getContainerHeight()); + Dimension d = null;///new Dimension(0, getContainerHeight()); return d; } diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuItemUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuItemUI.java index ea2a3d193..0dc69688f 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuItemUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuItemUI.java @@ -85,7 +85,6 @@ protected String getPropertyPrefix() { return "MenuItem"; } - public void processJ2SMenuCmd(Object[] data) { JSPopupMenuUI.processJ2SMenuCmd(data); } diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuUI.java index be1067552..a28a62ae2 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuUI.java @@ -1,6 +1,7 @@ package swingjs.plaf; import java.awt.Component; +import java.awt.Dimension; import java.awt.JSComponent; import java.beans.PropertyChangeEvent; @@ -113,16 +114,6 @@ protected int getChildCount() { return (isMenuItem ? 1 : jc.getComponentCount()); } -// @Override -// public Dimension getMaximumSize(JComponent jc) { -// return super.getPreferredSize(jc); -// } -// -// @Override -// public Dimension getPreferredSize(JComponent jc) { -// return super.getPreferredSize(jc); -// } - @Override protected String getPropertyPrefix() { return "Menu"; diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSPopupMenuUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSPopupMenuUI.java index 51c95843a..fef141cca 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSPopupMenuUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSPopupMenuUI.java @@ -232,8 +232,11 @@ public void setVisible(boolean b) { menu = (JPopupMenu) jc; j2sSwingMenu.setMenu(menu); isTainted = false; - JSComponent.秘getTopInvokableAncestor(jc, true).removeMouseListener(this); - JSComponent.秘getTopInvokableAncestor(jc, true).addMouseListener(this); + Component top = JSComponent.秘getTopInvokableAncestor(jc, true); + if (top != null) { + top.removeMouseListener(this); + top.addMouseListener(this); + } } else { updateMenu(true); } diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSProgressBarUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSProgressBarUI.java index d8e4a6b9e..c724a9870 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSProgressBarUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSProgressBarUI.java @@ -738,9 +738,8 @@ protected void paintDeterminate(Graphics g, JComponent c) { int amountFull = getAmountFull(b, barRectWidth, barRectHeight); Graphics2D g2 = (Graphics2D) g; - g2.setColor(progressBar.getForeground()); - if (progressBar.isIndeterminate()) { + g2.setColor(progressBar.getForeground()); DOMNode.setStyle(barNode, "display", "block"); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { DOMNode.setSize(barNode, barRectWidth, barRectHeight); @@ -751,6 +750,9 @@ protected void paintDeterminate(Graphics g, JComponent c) { } } else { DOMNode.setStyle(barNode, "display", "none"); + g2.setColor(progressBar.getBackground()); + g2.fillRect(b.left, b.top, barRectWidth, barRectHeight); + g2.setColor(progressBar.getForeground()); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { // draw the cells if (cellSpacing == 0 && amountFull > 0) { diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSSpinnerUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSSpinnerUI.java index 54a5b5942..46aff32a8 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSSpinnerUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSSpinnerUI.java @@ -56,8 +56,6 @@ */ public class JSSpinnerUI extends JSPanelUI { - private DOMNode up, dn; - @Override public DOMNode updateDOMNode() { spinner = (JSpinner) jc; @@ -855,60 +853,54 @@ public void propertyChange(PropertyChangeEvent e) { JSSpinnerUI ui = this; if (e.getSource() instanceof JSpinner) { JSpinner spinner = (JSpinner) (e.getSource()); -// JSSpinnerUI spinnerUI = spinner.getUI(); - -// if (spinnerUI instanceof JSSpinnerUI) { -// JSSpinnerUI ui = (JSSpinnerUI) spinnerUI; - - if ("editor".equals(prop)) { - JComponent oldEditor = (JComponent) e.getOldValue(); - JComponent newEditor = (JComponent) e.getNewValue(); - ui.replaceEditor(oldEditor, newEditor); - ui.updateEnabledState(); - if (oldEditor instanceof JSpinner.DefaultEditor) { - JTextField tf = ((JSpinner.DefaultEditor) oldEditor).getTextField(); - if (tf != null) { - tf.removeFocusListener(nextButtonHandler); - tf.removeFocusListener(previousButtonHandler); - } + switch (prop) { + case "editor": + JComponent oldEditor = (JComponent) e.getOldValue(); + JComponent newEditor = (JComponent) e.getNewValue(); + ui.replaceEditor(oldEditor, newEditor); + ui.updateEnabledState(); + if (oldEditor instanceof JSpinner.DefaultEditor) { + JTextField tf = ((JSpinner.DefaultEditor) oldEditor).getTextField(); + if (tf != null) { + tf.removeFocusListener(nextButtonHandler); + tf.removeFocusListener(previousButtonHandler); } - if (newEditor instanceof JSpinner.DefaultEditor) { - JTextField tf = ((JSpinner.DefaultEditor) newEditor).getTextField(); - if (tf != null) { - if (tf.getFont() instanceof UIResource) { - tf.setFont(spinner.getFont()); - } - tf.addFocusListener(nextButtonHandler); - tf.addFocusListener(previousButtonHandler); + } + if (newEditor instanceof JSpinner.DefaultEditor) { + JTextField tf = ((JSpinner.DefaultEditor) newEditor).getTextField(); + if (tf != null) { + if (tf.getFont() instanceof UIResource) { + tf.setFont(spinner.getFont()); } + tf.addFocusListener(nextButtonHandler); + tf.addFocusListener(previousButtonHandler); } - } else if ("enabled".equals(prop) || "model".equals(prop)) { - ui.updateEnabledState(); - } else if ("font".equals(prop)) { - JComponent editor = spinner.getEditor(); - if (editor != null && editor instanceof JSpinner.DefaultEditor) { - JTextField tf = ((JSpinner.DefaultEditor) editor).getTextField(); - if (tf != null) { - if (tf.getFont() instanceof UIResource) { - tf.setFont(spinner.getFont()); - } + } + break; + case "enabled": + case "model": + ui.updateEnabledState(); + break; + case "font": + JComponent editor = spinner.getEditor(); + if (editor != null && editor instanceof JSpinner.DefaultEditor) { + JTextField tf = ((JSpinner.DefaultEditor) editor).getTextField(); + if (tf != null) { + if (tf.getFont() instanceof UIResource) { + tf.setFont(spinner.getFont()); } } - } else if (JComponent.TOOL_TIP_TEXT_KEY.equals(prop)) { - updateToolTipTextForChildren(spinner); } - // } + break; + case JComponent.TOOL_TIP_TEXT_KEY: + updateToolTipTextForChildren(spinner); + break; + } } else if (e.getSource() instanceof JComponent) { JComponent c = (JComponent) e.getSource(); if ((c.getParent() instanceof JPanel) && (c.getParent().getParent() instanceof JSpinner) && "border".equals(prop)) { - - JSpinner spinner = (JSpinner) c.getParent().getParent(); -// SpinnerUI spinnerUI = spinner.getUI(); -// if (spinnerUI instanceof JSSpinnerUI) { -// JSSpinnerUI ui = (JSSpinnerUI) spinnerUI; - ui.maybeRemoveEditorBorder(c); -// } + ui.maybeRemoveEditorBorder(c); } } super.propertyChange(e); diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSTextFieldUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSTextFieldUI.java index 3520ae00a..be40d78c3 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSTextFieldUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSTextFieldUI.java @@ -99,6 +99,13 @@ public Dimension getPreferredSize(JComponent c) { return (isAWT ? getMinimumSize(c) : super.getPreferredSize(c)); } + @Override + protected String getSizingWidth() { + String text = editor.getText(); + return (text == null ? null : text.length() + "ch"); + } + + @Override diff --git a/sources/net.sf.j2s.java.core/src/test/JalviewJSTest.java b/sources/net.sf.j2s.java.core/src/test/JalviewJSTest.java index bf2c8c95b..cbf39351d 100644 --- a/sources/net.sf.j2s.java.core/src/test/JalviewJSTest.java +++ b/sources/net.sf.j2s.java.core/src/test/JalviewJSTest.java @@ -57,6 +57,8 @@ */ public class JalviewJSTest extends JPanel implements MenuListener, ItemListener { + // TODO: + // removeall and then restart public static final int SHIFT_DOWN_MASK; public static final int ALT_DOWN_MASK; public static final int SHORTCUT_MASK; @@ -430,10 +432,13 @@ public void actionPerformed(ActionEvent e) { Label awtlabel = new Label("AWT"); awtlabel.setFont(font); awtlabel.setAlignment(Label.LEFT); + // firstColumn.add(awtlabel); awtlabel.setBackground(Color.white); JButton b1 = new JButton("right left"); + b1.setContentAreaFilled(false); + b1.setIcon(getImage("test2.png")); b1.setFont(font); // totally ignored @@ -463,6 +468,9 @@ public void actionPerformed(ActionEvent e) { cb3.setFont(font); cb3.addActionListener((e) -> { System.out.println("cb3 checked " + cb3.isSelected()); + Font f = t1.getFont(); + t1.setFont(new Font(f.getFontName(), Font.PLAIN, f.getSize()+2)); + t1.setText(t1.getText() + "+"); }); cb3.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); diff --git a/sources/net.sf.j2s.java.core/src/test/Test_Anything.java b/sources/net.sf.j2s.java.core/src/test/Test_Anything.java index b0b7261b4..db5a281f6 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_Anything.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_Anything.java @@ -1,31 +1,50 @@ package test; +import java.awt.BorderLayout; + +import javax.swing.JButton; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JTextField; +import javax.swing.JToolBar; + public class Test_Anything extends javax.swing.JFrame { public Test_Anything() { - javax.swing.JPanel p = new javax.swing.JPanel(); - add(p); - this.setLocation(300, 300); - javax.swing.JButton b; - b = new javax.swing.JButton("FilesOpenDialog"); - b.addActionListener(new java.awt.event.ActionListener() { - - @Override - public void actionPerformed(java.awt.event.ActionEvent e) { - javax.swing.JFileChooser fc = new javax.swing.JFileChooser(); - fc.setMultiSelectionEnabled(true); - int f = fc.showOpenDialog(null); - System.out.println(f); - java.io.File[] files = fc.getSelectedFiles(); - for (int i = 0; i < files.length; i++) { - System.out.println(files[i] + " " + files[i].length()); - } - } - - }); - p.add(b); + JMenuBar mb2 = new JMenuBar(); + mb2.add(new JMenu("testing2")); + + setJMenuBar(mb2); + JTextField tf = new JTextField("test"); + System.out.println(tf.getPreferredSize()); +// add(BorderLayout.NORTH, tb); +// add(new JButton("OK")); +// +// +// javax.swing.JPanel p = new javax.swing.JPanel(); +// add(p); +// this.setLocation(300, 300); +// javax.swing.JButton b; +// +// b = new javax.swing.JButton("FilesOpenDialog"); +// b.addActionListener(new java.awt.event.ActionListener() { +// +// @Override +// public void actionPerformed(java.awt.event.ActionEvent e) { +// javax.swing.JFileChooser fc = new javax.swing.JFileChooser(); +// fc.setMultiSelectionEnabled(true); +// int f = fc.showOpenDialog(null); +// System.out.println(f); +// java.io.File[] files = fc.getSelectedFiles(); +// for (int i = 0; i < files.length; i++) { +// System.out.println(files[i] + " " + files[i].length()); +// } +// } +// +// }); +// p.add(b); pack(); setVisible(true); diff --git a/sources/net.sf.j2s.java.core/src/test/Test_Applet_2.java b/sources/net.sf.j2s.java.core/src/test/Test_Applet_2.java index 25f0d483e..460850819 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_Applet_2.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_Applet_2.java @@ -31,7 +31,10 @@ import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JFrame; import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; @@ -187,17 +190,27 @@ public void processEvent(AWTEvent e) { } } -// public static void main(String args[]) { -// JFrame f = new JFrame("Tanabe-Sugano"); + public static void main(String args[]) { + // Note -- SwingJS cannot add an applet to a frame. + JFrame f = new JFrame("Tanabe-Sugano"); // Test_Applet_2 tanabe = new Test_Applet_2(); +// JMenuBar mb = new JMenuBar(); +// mb.add(new JMenu("testing")); +// tanabe.setJMenuBar(mb); // tanabe.init(); // tanabe.start(); + + JMenuBar mb2 = new JMenuBar(); + mb2.add(new JMenu("testing2")); + f.setJMenuBar(mb2); + // f.add("Center", tanabe); -// f.setBackground(Color.white); -// f.pack(); -// f.setVisible(true); -// f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); -// } + f.setBackground(Color.white); + f.pack(); + + f.setVisible(true); + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } @Override public String getAppletInfo() { diff --git a/sources/net.sf.j2s.java.core/src/test/Test_Applet_Combo.java b/sources/net.sf.j2s.java.core/src/test/Test_Applet_Combo.java index acea6fd6c..12f427262 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_Applet_Combo.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_Applet_Combo.java @@ -107,6 +107,9 @@ public String getToolTipText() { @Override public void actionPerformed(ActionEvent e) { + c1.setFont(c1.getFont().deriveFont(c1.getFont().getSize() + 1.0f)); + System.out.println(c1.getFont()); + c1.setBackground(c1.getBackground() == Color.YELLOW ? Color.WHITE : Color.YELLOW); c1.setSelectedIndex((c1.getSelectedIndex() + 1) % c1.getItemCount()); } diff --git a/sources/net.sf.j2s.java.core/src/test/Test_Dialog.java b/sources/net.sf.j2s.java.core/src/test/Test_Dialog.java index 3d659dc52..1cd5b6bca 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_Dialog.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_Dialog.java @@ -143,7 +143,7 @@ public void actionPerformed(ActionEvent e) { }); p.add(b); - b = new JButton("MessageDialog"); + b = new JButton("Message1"); final JPanel message = new JPanel(); message.setLayout(new BorderLayout()); message.add(new JLabel("this is the message panel"), BorderLayout.CENTER); @@ -151,12 +151,26 @@ public void actionPerformed(ActionEvent e) { @Override public void actionPerformed(ActionEvent e) { - JOptionPane.showMessageDialog(Test_Dialog.this, message); + JOptionPane.showMessageDialog(Test_Dialog.this, message, "title", JOptionPane.WARNING_MESSAGE); + System.out.println("continuing1"); } }); p.add(b); + b = new JButton("Message2"); + b.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(Test_Dialog.this, "message", "title", JOptionPane.ERROR_MESSAGE); + System.out.println("continuing2"); + } + + }); + p.add(b); + + b = new JButton("InputDialog"); final JPanel input = new JPanel(); input.setLayout(new BorderLayout()); diff --git a/sources/net.sf.j2s.java.core/src/test/Test_Double.java b/sources/net.sf.j2s.java.core/src/test/Test_Double.java index e48cf36e8..eaa9f6b2b 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_Double.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_Double.java @@ -1,20 +1,26 @@ package test; +import javajs.util.DF; + class Test_Double extends Test_{ public static void main(String[] args) { - System.out.println(("" + new Double(3)).equals("3.0")); - System.out.println(("" + new Float(3)).equals("3.0")); - System.out.println(("" + new Double(3) * 3).equals("9.0")); + assert(DF.formatDecimal(-0.999999f, -4).equals("-1.000E+0")); + assert(DF.formatDecimal(9.999999f, -4).equals("1.000E+1")); + assert(DF.formatDecimal(9.999999f, 4).equals("10.0000")); + assert(DF.formatDecimal(9.999999f, 8).equals("9.99999900")); + assert(("" + new Double(3)).equals("3.0")); + assert(("" + new Float(3)).equals("3.0")); + assert(("" + new Double(3) * 3).equals("9.0")); float x = 3; float y = 3; int i = 3; - System.out.println(("" + x).equals("3.0")); - System.out.println(("" + y).equals("3.0")); - System.out.println(("" + x * y).equals("9.0")); - System.out.println(("" + (y + 0)).equals("3.0")); - System.out.println(("" + (i + 0.0)).equals("3.0")); - System.out.println(("" + Math.round(y)).equals("3")); + assert(("" + x).equals("3.0")); + assert(("" + y).equals("3.0")); + assert(("" + x * y).equals("9.0")); + assert(("" + (y + 0)).equals("3.0")); + assert(("" + (i + 0.0)).equals("3.0")); + assert(("" + Math.round(y)).equals("3")); assert (("" + new Double(3)).equals("3.0")); assert (("" + new Float(3)).equals("3.0")); diff --git a/sources/net.sf.j2s.java.core/src/test/Test_Editor.java b/sources/net.sf.j2s.java.core/src/test/Test_Editor.java index d42d5d19d..8ceed024b 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_Editor.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_Editor.java @@ -56,6 +56,8 @@ import javax.swing.Timer; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultCaret; import javax.swing.text.Document; @@ -758,6 +760,10 @@ public void addNotify() { }; JMenuItem mb1a = new JMenuItem("test-1"); + mb1a.addActionListener((e)->{ + System.out.println("test-1 clicked"); + }); + JMenuItem mb1b = new JMenuItem("test-2"); JMenuItem mb1c = new JMenuItem("test-3"); JMenuItem mb1d = new JMenuItem("test-4"); @@ -773,10 +779,33 @@ public void addNotify() { mb1e.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK)); mb1.add(mb1a); - mb1.add(mb1b); - mb1.add(mb1c); - mb1.add(mb1d); - mb1.add(mb1e); +// mb1.add(mb1b); +// mb1.add(mb1c); +// mb1.add(mb1d); +// mb1.add(mb1e); + mb1.addMenuListener(new MenuListener() { + + @Override + public void menuSelected(MenuEvent e) { + mb1.removeAll(); + mb1.add(mb1a); + // TODO Auto-generated method stub + + } + + @Override + public void menuDeselected(MenuEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void menuCanceled(MenuEvent e) { + // TODO Auto-generated method stub + + } + + }); KeyStroke[] a = mb1.getRegisteredKeyStrokes(); System.out.println("menubar menu registration: " + a.length); diff --git a/sources/net.sf.j2s.java.core/src/test/Test_File.java b/sources/net.sf.j2s.java.core/src/test/Test_File.java index 579e0dc2b..c1b3e6923 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_File.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_File.java @@ -18,6 +18,10 @@ public class Test_File extends Test_ { @SuppressWarnings("unused") public static void main(String[] args) { + File fff = new File("jar:file:testing/here"); + System.out.println(fff.getPath()); + System.out.println(fff.getAbsolutePath()); + testTempDir(); System.out.println(System.getProperty("jnlp.codebase")); diff --git a/sources/net.sf.j2s.java.core/src/test/Test_Menu.java b/sources/net.sf.j2s.java.core/src/test/Test_Menu.java new file mode 100644 index 000000000..8dc4a2189 --- /dev/null +++ b/sources/net.sf.j2s.java.core/src/test/Test_Menu.java @@ -0,0 +1,146 @@ +package test; + +import java.awt.BorderLayout; +//import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.DefaultKeyboardFocusManager; +import java.awt.Dimension; +import java.awt.Font; +//import java.awt.TextArea; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; + +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.KeyStroke; +import javax.swing.MenuElement; +import javax.swing.MenuSelectionManager; +import javax.swing.Timer; +import javax.swing.event.CaretEvent; +import javax.swing.event.CaretListener; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.DefaultCaret; +import javax.swing.text.Document; +import javax.swing.text.Element; +import javax.swing.text.JTextComponent; +import javax.swing.text.MutableAttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.Style; +import javax.swing.text.StyleConstants; + +public class Test_Menu extends JFrame { + public static void main(String[] args) { + new Test_Menu(); + } + + + protected boolean done; + + public Test_Menu() { + + setJMenuBar(getMenuBar()); + pack(); + setVisible(true); + } + + + private JMenuBar getMenuBar() { + JMenuBar mb = new JMenuBar(); + JMenu mb1 = new JMenu("Test1"); + JMenu mb2 = new JMenu("Test2"); + JMenuItem mb1a = new JMenuItem("test-1"); + mb1a.addActionListener((e)->{ + System.out.println("test-1 clicked"); + mb2.removeAll(); + mb1.add(mb1a); + System.out.println("test-1 removed and re-added"); + done = true; + }); + + + mb1.setMnemonic('t'); + mb1a.setMnemonic('1'); + + mb1.add(mb1a); + mb1.addMenuListener(new MenuListener() { + + @Override + public void menuSelected(MenuEvent e) { + mb1.add(mb1a); + // TODO Auto-generated method stub + + } + + @Override + public void menuDeselected(MenuEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void menuCanceled(MenuEvent e) { + // TODO Auto-generated method stub + + } + + }); + + + mb.add(mb1); + mb.add(mb2); + + ActionListener al = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + System.out.println("Test_Editor action " + e); + } + + }; + + mb1a.addActionListener(al); + + return mb; + } + +} diff --git a/sources/net.sf.j2s.java.core/src/test/Test_Video.java b/sources/net.sf.j2s.java.core/src/test/Test_Video.java index a92538aa4..eb3456906 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_Video.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_Video.java @@ -173,7 +173,7 @@ private void createDialog() { if (dialog != null) { dialog.dispose(); } - dialog = HTML5Video.createDialog(null, label, 500, new Function() { + dialog = HTML5Video.createDialog(null, label, 500, true, new Function() { @Override public Void apply(HTML5Video video) { diff --git a/sources/net.sf.j2s.java.core/src/test/components/ProgressBarSimpleDemo.java b/sources/net.sf.j2s.java.core/src/test/components/ProgressBarSimpleDemo.java index 013c443a4..41682e1ed 100644 --- a/sources/net.sf.j2s.java.core/src/test/components/ProgressBarSimpleDemo.java +++ b/sources/net.sf.j2s.java.core/src/test/components/ProgressBarSimpleDemo.java @@ -252,7 +252,7 @@ protected void onIdle() { } protected void onProgress() { - progressBar.setValue(++count); + progressBar.setValue((int) (Math.random() * max)); } protected void onDone() { diff --git a/sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js b/sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js index b8f24672b..f6dd58318 100644 --- a/sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js +++ b/sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js @@ -1,5 +1,6 @@ // j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu +// BH 2021.09.22 default file save as application/octet-stream, not text/plain // BH 2020.12.31 full 64-bit long // BH 2020.12.09 touch fixes for fdown and fdrag (j2sSlider) // BH 2020.12.03 note that relay is disabled using J2S.addDirectDatabaseCall(".") @@ -1267,7 +1268,7 @@ if (database == "_" && J2S._serverUrl.indexOf("//your.server.here/") >= 0) { // Asynchronous output generated using an anchor tag var a = document.createElement("a"); a.href = "data:" + mimetype + ";base64," + data; - a.type = mimetype || (mimetype = "text/plain;charset=utf-8"); + a.type = mimetype || (mimetype = "application/octet-stream");//was "text/plain;charset=utf-8"); a.download = filename; a.target = "_blank"; $("body").append(a); 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 efcad68b3..a3e911dc7 100644 --- a/sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js +++ b/sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js @@ -7,6 +7,7 @@ // Google closure compiler cannot handle Clazz.new or Clazz.super +// BH 2021.08.16 fix for Interface initalizing its subclass with static initialization // BH 2021.07.28 String.instantialize upgraded to use TextDecoder() if possible (not in MSIE) // BH 2021.07.20 Date.toString() format yyyy moved to end, as in Java // BH 2021.06.11 Number.compareTo(....) missing @@ -394,7 +395,7 @@ var initStatic = function(cl, impls) { } else if (cl.superclazz) { initStatic(cl.superclazz); } - cl.$static$ && cl.$static$(); + cl.$static$ && (initStatics(cl), cl.$static$()); } /** @@ -462,11 +463,13 @@ var initClass0 = function(c) { var fields = c.$fields$; var objects = fields && fields[0]; createDefaults(c, objects, false); - if (!fields) - return; - var statics = fields[1]; + fields && initStatics(c); +} + +var initStatics = function(c) { + var statics = c.$fields$ && c.$fields$[1]; if (statics && statics.length) - createDefaults(c, statics, true); + createDefaults(c, statics, true); } //C$.$fields$=[ @@ -477,20 +480,20 @@ var createDefaults = function(c, data, isStatic) { var a = getFields(c, data, true); if (isStatic) { for (var i = a.length; --i >= 0;) { - c[a[i][0]] = a[i][1]; + var j = a[i][0]; + if (c[j] != undefined) + return; + c[j] = a[i][1]; } - } else { - c.$init0$ = - //(function(cs, a) {return - function(){ - var cs = c.superclazz; - cs && cs.$init0$ && cs.$init0$.apply(this); - for (var i = a.length; --i >= 0;){ - this[a[i][0]] = a[i][1]; - } - }; -// })(c.superclazz, a); + return; } + c.$init0$ = function(){ + var cs = c.superclazz; + cs && cs.$init0$ && cs.$init0$.apply(this); + for (var i = a.length; --i >= 0;){ + this[a[i][0]] = a[i][1]; + } + }; } @@ -2387,7 +2390,7 @@ _Loader.setClasspathFor = function(clazzes) { if (!(clazzes instanceof Array)) clazzes = [clazzes]; for (var i = clazzes.length; --i >= 0;) { - path = clazzes[i]; + var path = clazzes[i]; var jar = _Loader.getJ2SLibBase() + path.split(".")[0]+".js"; path = path.replace(/\//g,"."); classpathMap["#" + path] = jar; @@ -3848,9 +3851,9 @@ var radix=(n.startsWith("0x", i) ? 16 : n.startsWith("0", i) ? 8 : 10); // The general problem with parseInt is that is not strict -- ParseInt("10whatever") == 10. // Number is strict, but Number("055") does not work, though ParseInt("055", 8) does. // need to make sure negative numbers are negative -if (n == "") - return NaN -n = Number(n) & 0xFFFFFFFF; +if (n == "" || radix == 10 && isNaN(+n)) + return NaN +n = (+n) & 0xFFFFFFFF; return (radix == 8 ? parseInt(n, 8) : n); }, 1); diff --git a/sources/net.sf.j2s.java.core/srcjs/swingjs2.js b/sources/net.sf.j2s.java.core/srcjs/swingjs2.js index c7ec20187..ea6253f1a 100644 --- a/sources/net.sf.j2s.java.core/srcjs/swingjs2.js +++ b/sources/net.sf.j2s.java.core/srcjs/swingjs2.js @@ -10671,6 +10671,7 @@ return jQuery; })(jQuery,document,"click mousemove mouseup touchmove touchend", "outjsmol"); // j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu +// BH 2021.09.22 default file save as application/octet-stream, not text/plain // BH 2020.12.31 full 64-bit long // BH 2020.12.09 touch fixes for fdown and fdrag (j2sSlider) // BH 2020.12.03 note that relay is disabled using J2S.addDirectDatabaseCall(".") @@ -11938,7 +11939,7 @@ if (database == "_" && J2S._serverUrl.indexOf("//your.server.here/") >= 0) { // Asynchronous output generated using an anchor tag var a = document.createElement("a"); a.href = "data:" + mimetype + ";base64," + data; - a.type = mimetype || (mimetype = "text/plain;charset=utf-8"); + a.type = mimetype || (mimetype = "application/octet-stream");//was "text/plain;charset=utf-8"); a.download = filename; a.target = "_blank"; $("body").append(a); @@ -14022,6 +14023,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) { // Google closure compiler cannot handle Clazz.new or Clazz.super +// BH 2021.08.16 fix for Interface initalizing its subclass with static initialization // BH 2021.07.28 String.instantialize upgraded to use TextDecoder() if possible (not in MSIE) // BH 2021.07.20 Date.toString() format yyyy moved to end, as in Java // BH 2021.06.11 Number.compareTo(....) missing @@ -14409,7 +14411,7 @@ var initStatic = function(cl, impls) { } else if (cl.superclazz) { initStatic(cl.superclazz); } - cl.$static$ && cl.$static$(); + cl.$static$ && (initStatics(cl), cl.$static$()); } /** @@ -14477,11 +14479,13 @@ var initClass0 = function(c) { var fields = c.$fields$; var objects = fields && fields[0]; createDefaults(c, objects, false); - if (!fields) - return; - var statics = fields[1]; + fields && initStatics(c); +} + +var initStatics = function(c) { + var statics = c.$fields$ && c.$fields$[1]; if (statics && statics.length) - createDefaults(c, statics, true); + createDefaults(c, statics, true); } //C$.$fields$=[ @@ -14492,20 +14496,20 @@ var createDefaults = function(c, data, isStatic) { var a = getFields(c, data, true); if (isStatic) { for (var i = a.length; --i >= 0;) { - c[a[i][0]] = a[i][1]; + var j = a[i][0]; + if (c[j] != undefined) + return; + c[j] = a[i][1]; } - } else { - c.$init0$ = - //(function(cs, a) {return - function(){ - var cs = c.superclazz; - cs && cs.$init0$ && cs.$init0$.apply(this); - for (var i = a.length; --i >= 0;){ - this[a[i][0]] = a[i][1]; - } - }; -// })(c.superclazz, a); + return; } + c.$init0$ = function(){ + var cs = c.superclazz; + cs && cs.$init0$ && cs.$init0$.apply(this); + for (var i = a.length; --i >= 0;){ + this[a[i][0]] = a[i][1]; + } + }; } @@ -16402,7 +16406,7 @@ _Loader.setClasspathFor = function(clazzes) { if (!(clazzes instanceof Array)) clazzes = [clazzes]; for (var i = clazzes.length; --i >= 0;) { - path = clazzes[i]; + var path = clazzes[i]; var jar = _Loader.getJ2SLibBase() + path.split(".")[0]+".js"; path = path.replace(/\//g,"."); classpathMap["#" + path] = jar; @@ -17863,9 +17867,9 @@ var radix=(n.startsWith("0x", i) ? 16 : n.startsWith("0", i) ? 8 : 10); // The general problem with parseInt is that is not strict -- ParseInt("10whatever") == 10. // Number is strict, but Number("055") does not work, though ParseInt("055", 8) does. // need to make sure negative numbers are negative -if (n == "") - return NaN -n = Number(n) & 0xFFFFFFFF; +if (n == "" || radix == 10 && isNaN(+n)) + return NaN +n = (+n) & 0xFFFFFFFF; return (radix == 8 ? parseInt(n, 8) : n); }, 1);