Skip to content

Commit dda0a6d

Browse files
hansonrhansonr
authored andcommitted
+DefaultDesktopManager for JInternalFrames File.createTempFile
fixes for FileInputStream and FileOutputStream. File appending works, but you must first read the file, then append.
1 parent 40bd677 commit dda0a6d

29 files changed

+2251
-184
lines changed
7.53 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180823095007
1+
20180824015733
7.53 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180823095007
1+
20180824015733
7.53 KB
Binary file not shown.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ public VKCollection() {
840840
* for (var k in C$)
841841
* if (k.indexOf("VK_") == 0) {
842842
* try {
843-
* this.put$S$I(k, Integer.valueOf$I(C$[k]));
843+
* this.put$S$Integer(k, Integer.valueOf$I(C$[k]));
844844
* } catch (e) {}
845845
* }
846846
*/

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.EventListener;
3434
import java.util.Set;
3535

36+
import javax.swing.JInternalFrame;
3637
import javax.swing.table.TableCellRenderer;
3738

3839
import javajs.util.Lst;
@@ -51,8 +52,11 @@
5152
import java.awt.peer.ContainerPeer;
5253
import java.awt.peer.LightweightPeer;
5354
import java.beans.PropertyChangeListener;
55+
import java.beans.PropertyVetoException;
56+
5457
import sun.awt.AppContext;
5558
import sun.awt.SunGraphicsCallback;
59+
import swingjs.JSFrameViewer;
5660
import swingjs.plaf.JSButtonUI;
5761
import swingjs.plaf.JSComponentUI;
5862
import swingjs.plaf.JSTableUI;
@@ -720,10 +724,13 @@ public void setComponentZOrder(Component comp, int index) {
720724
// this is actually a Z-order changing.
721725
comp.mixOnZOrderChanging(oldZindex, index);
722726
}
727+
728+
updateUIZOrder((JSComponent[]) getComponents());
729+
723730
}
724731
}
725732

726-
/**
733+
/**
727734
* Traverses the tree of components and reparents children heavyweight component
728735
* to new heavyweight parent.
729736
* @since 1.5
@@ -4413,6 +4420,7 @@ private boolean processMouseEvent(MouseEvent e) {
44134420
case MouseEvent.MOUSE_EXITED:
44144421
break;
44154422
case MouseEvent.MOUSE_PRESSED:
4423+
checkInternalFrameMouseDown((JSComponent) e.getSource());
44164424
retargetMouseEvent(mouseEventTarget, id, e);
44174425
break;
44184426
case MouseEvent.MOUSE_RELEASED:
@@ -4495,7 +4503,16 @@ private boolean processMouseEvent(MouseEvent e) {
44954503
// return e.isConsumed();
44964504
// }
44974505

4498-
/*
4506+
public void checkInternalFrameMouseDown(JSComponent c) {
4507+
JSFrameViewer fv = c.getFrameViewer();
4508+
if (fv.top.uiClassID == "InternalFrameUI")
4509+
try {
4510+
((JInternalFrame) fv.top).setSelected(true);
4511+
} catch (PropertyVetoException e) {
4512+
}
4513+
}
4514+
4515+
/*
44994516
* Generates enter/exit events as mouse moves over lw components
45004517
* @param targetOver Target mouse is over (including native container)
45014518
* @param e Mouse event in native container

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public class Frame extends Window {
315315
* @serial
316316
* @see #isResizable()
317317
*/
318-
boolean resizable = true;
318+
protected boolean resizable = true;
319319

320320
/**
321321
* This field indicates whether the frame is undecorated.

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import java.awt.peer.ComponentPeer;
3131
import java.beans.PropertyChangeListener;
32+
import java.util.Arrays;
3233

3334
import javax.swing.ArrayTable;
3435
import javax.swing.JComponent;
@@ -40,7 +41,9 @@
4041
import swingjs.JSAppletViewer;
4142
import swingjs.JSFrameViewer;
4243
import swingjs.JSGraphics2D;
44+
import swingjs.api.js.DOMNode;
4345
import swingjs.api.js.HTML5Canvas;
46+
import swingjs.plaf.JSComponentUI;
4447

4548
/*
4649
* A class to support swingJS for selected AWT and Swing components
@@ -276,4 +279,23 @@ public boolean isBackgroundSet() {
276279
// !isBackgroundPainted);
277280
}
278281

282+
protected void updateUIZOrder(JSComponent[] components) {
283+
if (uiClassID != "DesktopPaneUI")
284+
return;
285+
// set the n by their position in the component list using the
286+
// same z orders that are already there - probably something like
287+
// 10000, 11000, 12000
288+
int n = components.length;
289+
if (n < 2)
290+
return;
291+
int[] zorders = new int[n];
292+
for (int i = 0; i < n; i++)
293+
zorders[i] = ((JSComponentUI) components[i].getUI()).getZIndex(null);
294+
Arrays.sort(zorders);
295+
for (int i = 0; i < n; i++)
296+
((JSComponentUI) components[i].getUI()).setZOrder(zorders[n - 1 - i]);
297+
}
298+
299+
300+
279301
}

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public class File
139139
{
140140

141141

142-
protected int _bytes; // filled in by SwingJS ajax call
142+
protected byte[] _bytes; // filled in by SwingJS ajax call
143143
//
144144
// /**
145145
// * The FileSystem object representing the platform's local file system.
@@ -153,7 +153,7 @@ public class File
153153
*
154154
* @serial
155155
*/
156-
private String path;
156+
protected String path;
157157

158158
/**
159159
* The length of this abstract pathname's prefix, or zero if it has no
@@ -1733,13 +1733,13 @@ public boolean canExecute() {
17331733
//// private static class LazyInitialization {
17341734
//// static final SecureRandom random = new SecureRandom();
17351735
////
1736-
static final String temporaryDirectory = temporaryDirectory();
1737-
static String temporaryDirectory() {
1738-
return "/TEMP/";
1736+
static final String temporaryDirectory = "/TEMP/";//temporaryDirectory();
1737+
// static String temporaryDirectory() {
1738+
// return "/TEMP/";
17391739
// return fs.normalize(
17401740
// AccessController.doPrivileged(
17411741
// new GetPropertyAction("java.io.tmpdir")));
1742-
}
1742+
// }
17431743
//// }
17441744
//
17451745
private static File generateFile(String prefix, String suffix, File dir)
@@ -1781,10 +1781,12 @@ private static File createTempFile0(String prefix, String suffix,
17811781
if (prefix.length() < 3)
17821782
throw new IllegalArgumentException("Prefix string too short");
17831783
String s = (suffix == null) ? ".tmp" : suffix;
1784-
if (directory == null) {
1785-
String tmpDir = temporaryDirectory();
1786-
directory = new File(tmpDir);//, fs.prefixLength(tmpDir));
1787-
}
1784+
directory = new File(temporaryDirectory + (directory == null ? "" : directory));
1785+
// we ensure that there is a clear marker for a temporary directory in SwingJS
1786+
// if (directory == null) {
1787+
// String tmpDir = temporaryDirectory();
1788+
// directory = new File(tmpDir);//, fs.prefixLength(tmpDir));
1789+
// }
17881790
// SecurityManager sm = System.getSecurityManager();
17891791
File f;
17901792
// do {

0 commit comments

Comments
 (0)