Skip to content

Commit f26bd87

Browse files
authored
Merge pull request #225 from BobHanson/hanson1
Hanson1
2 parents 8429329 + 682511a commit f26bd87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+683
-326
lines changed
2.56 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20210728172208
1+
20211009053211
2.56 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20210728172208
1+
20211009053211
2.56 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/Container.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.EventListener;
4646
import java.util.Set;
4747

48+
import javax.swing.JApplet;
4849
import javax.swing.JInternalFrame;
4950

5051
import javajs.util.Lst;
@@ -1087,6 +1088,10 @@ protected void addImplCont(Component comp, Object constraints, int index) {
10871088
comp.background = comp.foreground = null; // this parent should not set the background color
10881089
}
10891090
// SwingJS used for all add methods
1091+
// When adding an applet, we should just add its content pane
1092+
if (comp instanceof JApplet) {
1093+
comp = ((JApplet)comp).getLayeredPane();
1094+
}
10901095

10911096
/*
10921097
* Check for correct arguments: index in bounds, comp cannot be one of this

sources/net.sf.j2s.java.core/src/java/awt/Font.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ public Font deriveFont(float sizePts) {
19771977
return f;
19781978
}
19791979
AttributeValues newValues = getAttributeValues().clone();
1980-
newValues.setSize(size);
1980+
newValues.setSize(sizePts);
19811981
return new Font(newValues, null, -1, createdFont, font2DHandle);
19821982
}
19831983

sources/net.sf.j2s.java.core/src/java/awt/Window.java

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ public void setTrayIconWindow(boolean isTrayIconWindow) {
386386
//
387387
// private static final Logger log = Logger.getLogger("java.awt.Window");
388388

389-
// private static final boolean locationByPlatformProp;
389+
private static final boolean locationByPlatformProp = false;
390390

391391
transient boolean isTrayIconWindow = false;
392392

@@ -536,7 +536,8 @@ public Window(Window owner) {
536536
public Window(Window owner, GraphicsConfiguration gc) {
537537
super();
538538
秘winOrApplet = true;
539-
秘paintClass = 秘updateClass = /**@j2sNative C$ || */null;
539+
秘paintClass = 秘updateClass = /** @j2sNative C$ || */
540+
null;
540541
setAppContext();
541542
parent = owner;
542543
if (owner != null)
@@ -567,16 +568,15 @@ public Window(Window owner, GraphicsConfiguration gc) {
567568

568569
/* offset the initial location with the original of the screen */
569570
/* and any insets */
570-
// SwingJS TODO ??
571-
// Rectangle screenBounds = graphicsConfig.getBounds();
572-
// Insets screenInsets = getToolkit().getScreenInsets(graphicsConfig);
573-
// int x = getX() + screenBounds.x + screenInsets.left;
574-
// int y = getY() + screenBounds.y + screenInsets.top;
575-
// if (x != this.x || y != this.y) {
576-
// setLocation(x, y);
577-
// /* reset after setLocation */
578-
// // setLocationByPlatform(locationByPlatformProp);
579-
// }
571+
Rectangle screenBounds = getGraphicsConfiguration().getBounds();
572+
Insets screenInsets = getToolkit().getScreenInsets(graphicsConfig);
573+
int x = getX() + screenBounds.x + screenInsets.left;
574+
int y = getY() + screenBounds.y + screenInsets.top;
575+
if (x != ((Container) this).x || y != ((Container) this).y) {
576+
setLocation(x, y);
577+
/* reset after setLocation */
578+
setLocationByPlatform(locationByPlatformProp);
579+
}
580580

581581
modalExclusionType = ModalExclusionType.NO_EXCLUDE;
582582

@@ -3159,80 +3159,80 @@ protected boolean canContainFocusOwner(Component focusOwnerCandidate) {
31593159
return super.canContainFocusOwner(focusOwnerCandidate) && isFocusableWindow();
31603160
}
31613161

3162-
// private boolean locationByPlatform = locationByPlatformProp;
3163-
3164-
// /**
3165-
// * Sets whether this Window should appear at the default location for the
3166-
// * native windowing system or at the current location (returned by
3167-
// * <code>getLocation</code>) the next time the Window is made visible.
3168-
// * This behavior resembles a native window shown without programmatically
3169-
// * setting its location. Most windowing systems cascade windows if their
3170-
// * locations are not explicitly set. The actual location is determined once the
3171-
// * window is shown on the screen.
3172-
// * <p>
3173-
// * This behavior can also be enabled by setting the System Property
3174-
// * "java.awt.Window.locationByPlatform" to "true", though calls to this method
3175-
// * take precedence.
3176-
// * <p>
3177-
// * Calls to <code>setVisible</code>, <code>setLocation</code> and
3178-
// * <code>setBounds</code> after calling <code>setLocationByPlatform</code> clear
3179-
// * this property of the Window.
3180-
// * <p>
3181-
// * For example, after the following code is executed:
3182-
// * <pre><blockquote>
3183-
// * setLocationByPlatform(true);
3184-
// * setVisible(true);
3185-
// * boolean flag = isLocationByPlatform();
3186-
// * </blockquote></pre>
3187-
// * The window will be shown at platform's default location and
3188-
// * <code>flag</code> will be <code>false</code>.
3189-
// * <p>
3190-
// * In the following sample:
3191-
// * <pre><blockquote>
3192-
// * setLocationByPlatform(true);
3193-
// * setLocation(10, 10);
3194-
// * boolean flag = isLocationByPlatform();
3195-
// * setVisible(true);
3196-
// * </blockquote></pre>
3197-
// * The window will be shown at (10, 10) and <code>flag</code> will be
3198-
// * <code>false</code>.
3199-
// *
3200-
// * @param locationByPlatform <code>true</code> if this Window should appear
3201-
// * at the default location, <code>false</code> if at the current location
3202-
// * @throws <code>IllegalComponentStateException</code> if the window
3203-
// * is showing on screen and locationByPlatform is <code>true</code>.
3204-
// * @see #setLocation
3205-
// * @see #isShowing
3206-
// * @see #setVisible
3207-
// * @see #isLocationByPlatform
3208-
// * @see java.lang.System#getProperty(String)
3209-
// * @since 1.5
3210-
// */
3211-
// public void setLocationByPlatform(boolean locationByPlatform) {
3162+
private boolean locationByPlatform = locationByPlatformProp;
3163+
3164+
/**
3165+
* Sets whether this Window should appear at the default location for the
3166+
* native windowing system or at the current location (returned by
3167+
* <code>getLocation</code>) the next time the Window is made visible.
3168+
* This behavior resembles a native window shown without programmatically
3169+
* setting its location. Most windowing systems cascade windows if their
3170+
* locations are not explicitly set. The actual location is determined once the
3171+
* window is shown on the screen.
3172+
* <p>
3173+
* This behavior can also be enabled by setting the System Property
3174+
* "java.awt.Window.locationByPlatform" to "true", though calls to this method
3175+
* take precedence.
3176+
* <p>
3177+
* Calls to <code>setVisible</code>, <code>setLocation</code> and
3178+
* <code>setBounds</code> after calling <code>setLocationByPlatform</code> clear
3179+
* this property of the Window.
3180+
* <p>
3181+
* For example, after the following code is executed:
3182+
* <pre><blockquote>
3183+
* setLocationByPlatform(true);
3184+
* setVisible(true);
3185+
* boolean flag = isLocationByPlatform();
3186+
* </blockquote></pre>
3187+
* The window will be shown at platform's default location and
3188+
* <code>flag</code> will be <code>false</code>.
3189+
* <p>
3190+
* In the following sample:
3191+
* <pre><blockquote>
3192+
* setLocationByPlatform(true);
3193+
* setLocation(10, 10);
3194+
* boolean flag = isLocationByPlatform();
3195+
* setVisible(true);
3196+
* </blockquote></pre>
3197+
* The window will be shown at (10, 10) and <code>flag</code> will be
3198+
* <code>false</code>.
3199+
*
3200+
* @param locationByPlatform <code>true</code> if this Window should appear
3201+
* at the default location, <code>false</code> if at the current location
3202+
* @throws <code>IllegalComponentStateException</code> if the window
3203+
* is showing on screen and locationByPlatform is <code>true</code>.
3204+
* @see #setLocation
3205+
* @see #isShowing
3206+
* @see #setVisible
3207+
* @see #isLocationByPlatform
3208+
* @see java.lang.System#getProperty(String)
3209+
* @since 1.5
3210+
*/
3211+
public void setLocationByPlatform(boolean locationByPlatform) {
3212+
synchronized (getTreeLock()) {
3213+
if (locationByPlatform && isShowing()) {
3214+
throw new IllegalComponentStateException("The window is showing on screen.");
3215+
}
3216+
this.locationByPlatform = locationByPlatform;
3217+
}
3218+
}
3219+
3220+
/**
3221+
* Returns <code>true</code> if this Window will appear at the default location
3222+
* for the native windowing system the next time this Window is made visible.
3223+
* This method always returns <code>false</code> if the Window is showing on the
3224+
* screen.
3225+
*
3226+
* @return whether this Window will appear at the default location
3227+
* @see #setLocationByPlatform
3228+
* @see #isShowing
3229+
* @since 1.5
3230+
*/
3231+
public boolean isLocationByPlatform() {
32123232
// synchronized (getTreeLock()) {
3213-
// if (locationByPlatform && isShowing()) {
3214-
// throw new IllegalComponentStateException("The window is showing on screen.");
3215-
// }
3216-
// this.locationByPlatform = locationByPlatform;
3217-
// }
3218-
// }
3219-
3220-
// /**
3221-
// * Returns <code>true</code> if this Window will appear at the default location
3222-
// * for the native windowing system the next time this Window is made visible.
3223-
// * This method always returns <code>false</code> if the Window is showing on the
3224-
// * screen.
3225-
// *
3226-
// * @return whether this Window will appear at the default location
3227-
// * @see #setLocationByPlatform
3228-
// * @see #isShowing
3229-
// * @since 1.5
3230-
// */
3231-
// public boolean isLocationByPlatform() {
3232-
// synchronized (getTreeLock()) {
3233-
// return locationByPlatform;
3234-
// }
3235-
// }
3233+
return locationByPlatform;
3234+
// }
3235+
}
32363236

32373237
/**
32383238
* {@inheritDoc}

sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ public ColorModel getColorModel() {
913913
* @return the <code>WriteableRaster</code> of this <code>BufferedImage</code> .
914914
*/
915915
public WritableRaster getRaster() {
916+
// ok, but raster.getDataBuffer().getData() is going to require a flush();
916917
return raster;
917918
}
918919

sources/net.sf.j2s.java.core/src/javajs/async/Assets.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,11 @@ private static InputStream getAssetStream(String path, boolean zipOnly) {
406406
if (url == null && !zipOnly) {
407407
url = Assets.class.getClassLoader().getResource(path);
408408
}
409-
InputStream is = null;
410409
try {
411-
is = url.openStream();
410+
return (url == null ? null : url.openStream());
412411
} catch (Throwable t) {
413412
}
414-
return is;
413+
return null;
415414
}
416415
/**
417416
* Determine the path to an asset. If not found in a zip file asset, return the

0 commit comments

Comments
 (0)