Skip to content

Commit 8c8e437

Browse files
authored
Merge pull request #145 from BobHanson/hanson1
fix for menu item, slider, applet, Files.readAllBytes
2 parents 9affb1d + 1cd3ab6 commit 8c8e437

File tree

20 files changed

+125
-55
lines changed

20 files changed

+125
-55
lines changed
1.17 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200119225004
1+
20200124055240
1.17 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200119225004
1+
20200124055240
1.17 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/applet/JSApplet.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
import javax.swing.JRootPane;
4444
import javax.swing.RepaintManager;
4545

46+
import swingjs.plaf.JSAppletUI;
47+
4648
/**
4749
* SwingJS note: This class is the original java.applet.Applet class.
4850
* It is subclassed by JApplet. The replacement java.applet.Applet class
@@ -290,6 +292,7 @@ public void resizeHTML(int width, int height) {
290292
// ((JSComponentUI)root.getUI()).setPainted(null);
291293
// root.秘isBackgroundPainted = false;
292294
RepaintManager.currentManager(this).addInvalidComponent(root);
295+
((JSAppletUI)getUI()).adjustCanvasForMenuBar();
293296
}
294297
}
295298
}

sources/net.sf.j2s.java.core/src/java/io/FileDescriptor.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ public final class FileDescriptor {
5656
*/
5757
File _file;
5858

59+
public byte[] _getBytes(boolean checkDisk) {
60+
if (_file.秘bytes == null && checkDisk) {
61+
// a check for file existence sets the bytes
62+
_file.exists();
63+
}
64+
return _file.秘bytes;
65+
}
66+
5967
private int pos, len = -1;
6068

6169
public void _setPosAndLen(int pos, int len) {
@@ -283,5 +291,4 @@ synchronized void closeAll(Closeable releaser) throws IOException {
283291
}
284292
}
285293

286-
287294
}

sources/net.sf.j2s.java.core/src/java/io/FileSystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private boolean _regular(File file) {
115115
}
116116

117117
boolean _exists(File file) {
118-
return (file.秘bytes != null || JSUtil.getFileAsBytes(file) != null);
118+
return (file.秘bytes != null || (file.秘bytes=JSUtil.getFileAsBytes(file)) != null);
119119
}
120120

121121
boolean _isDir(File file) {

sources/net.sf.j2s.java.core/src/java/nio/channels/ByteChannel.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525

2626
package java.nio.channels;
2727

28-
import java.io.IOException;
29-
30-
3128
/**
3229
* A channel that can read and write bytes. This interface simply unifies
3330
* {@link ReadableByteChannel} and {@link WritableByteChannel}; it does not

sources/net.sf.j2s.java.core/src/swingjs/JSFileSystem.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ private JSFileChannel(FileDescriptor fd, String path, boolean readable, boolean
121121
this.fd = fd;
122122
this.parent = parent;
123123
this.path = (JSPath) new File(path).toPath();
124+
if (fd != null && (readable || append))
125+
this.path.秘bytes = fd._getBytes(true);
124126
this.path.setIsTempFile(fd._isTempFile());
125127
Set<StandardOpenOption> options = new HashSet<>();
126128
if (readable)
@@ -406,6 +408,10 @@ public JSByteChannel(FileDescriptor fd, JSPath path, Set<? extends OpenOption> o
406408
boolean truncate = options.contains(StandardOpenOption.TRUNCATE_EXISTING);
407409
boolean create = options.contains(StandardOpenOption.CREATE);
408410
boolean createNew = options.contains(StandardOpenOption.CREATE_NEW);
411+
if ((read ||append) && path.秘bytes == null && fd != null) {
412+
path.秘bytes = fd._getBytes(true);
413+
}
414+
409415
if (read && write) {
410416
秘bytes = getBytes();
411417
if (秘bytes == null) {

0 commit comments

Comments
 (0)