Skip to content

Commit 677227e

Browse files
committed
new tests, SwingJS-site.zip
1 parent d62a141 commit 677227e

File tree

9 files changed

+76
-6
lines changed

9 files changed

+76
-6
lines changed
-706 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200405214840
1+
20200408084722
-706 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200405214840
1+
20200408084722
-706 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/test/Test_Applet_Scroll.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public void paintComponent(Graphics g) {
401401
label.setHorizontalAlignment(SwingConstants.RIGHT);
402402
label.setVerticalAlignment(SwingConstants.CENTER);
403403

404-
final JTextField tf = new JTextField(/** @j2sNative "JS" ||*/null, "12.5", 8);
404+
final JTextField tf = new JTextField(/** @j2sNative "null" ||*/null, "12.5", 8);
405405
// final JTextField tf = new JTextField(new PlainDocument() {
406406
// @Override
407407
// public void getText(int offset, int length, Segment txt) throws BadLocationException {

sources/net.sf.j2s.java.core/src/test/Test_Html.java

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package test;
22

3+
import java.awt.Font;
34
import java.net.URL;
45

6+
import javax.swing.JButton;
57
import javax.swing.JEditorPane;
68
import javax.swing.JFrame;
79
import javax.swing.event.HyperlinkEvent;
810
import javax.swing.event.HyperlinkListener;
911
import javax.swing.text.AttributeSet;
12+
import javax.swing.text.Document;
1013
import javax.swing.text.Element;
1114
import javax.swing.text.html.HTML;
1215
import javax.swing.text.html.HTMLDocument;
@@ -20,6 +23,10 @@ public Test_Html() {
2023
JEditorPane editor = new JEditorPane();
2124
editor.setEditable(false);
2225
editor.setEditorKit(new HTMLEditorKit());
26+
HTMLDocument document = (HTMLDocument) editor.getDocument();
27+
document.getStyleSheet().addRule(getBodyStyle());
28+
document.getStyleSheet().addRule(getH1Style());
29+
document.getStyleSheet().addRule(getH2Style());
2330
editor.setText(
2431
"<html>"
2532
+ "<head><base href=http://phet.colorado.edu>"
@@ -29,7 +36,7 @@ public Test_Html() {
2936
+ "</style>"
3037
+ "</head>"
3138
+ "<body>"
32-
+ "<b><font color=red>PhET Interactive Simulations</font></b>"
39+
+ "<b><h2><font color=red>PhET Interactive Simulations</font></h2></b>"
3340
+ "<br>Copyright &copy; 2004-2015 University of Colorado."
3441
+ "<br><a href=\"about/licensing.php\">Some rights reserved.</a>"
3542
+ "<br>Visit <a href=\".\">http://phet.colorado.edu</a>"
@@ -79,4 +86,49 @@ public static void main(String[] args) {
7986

8087
}
8188

89+
/**
90+
* Returns the body style for a stylesheet.
91+
*
92+
* @return the body style
93+
*/
94+
protected static String getBodyStyle() {
95+
return
96+
"body {\n"+ //$NON-NLS-1$
97+
" font-family: Verdana, Arial, Helvetica, sans-serif;\n"+ //$NON-NLS-1$
98+
" font-size: "+bodyFont.getSize()+"pt;\n"+ //$NON-NLS-1$ //$NON-NLS-2$
99+
" color: #405050;\n"+ //$NON-NLS-1$
100+
" background-color: #FFFFFF;\n"+ //$NON-NLS-1$
101+
"}\n"; //$NON-NLS-1$
102+
}
103+
104+
/**
105+
* Returns the H1 heading style for a stylesheet.
106+
*
107+
* @return the H1 heading style
108+
*/
109+
protected static String getH1Style() {
110+
return
111+
"h1 {\n"+
112+
" font-size: "+h1Font.getSize()+"pt;\n"+
113+
" text-align: center;\n"+
114+
"}\n";
115+
}
116+
117+
/**
118+
* Returns the H2 heading style for a stylesheet.
119+
*
120+
* @return the H2 heading style
121+
*/
122+
protected static String getH2Style() {
123+
return
124+
"h2 {\n"+
125+
" font-size: "+h2Font.getSize()+"pt;\n"+
126+
"}\n";
127+
}
128+
129+
protected static Font bodyFont = new JButton().getFont().deriveFont(12f);
130+
protected static Font h1Font = bodyFont.deriveFont(24f);
131+
protected static Font h2Font = bodyFont.deriveFont(16f);
132+
133+
82134
}

sources/net.sf.j2s.java.core/src/test/Test_Map.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,14 @@ class Test_Map extends Test_ {
5353

5454
public static void main(String[] args) {
5555

56+
5657
System.out.println("Equivalence tests asserted");
5758
assert(new Integer(3) == 3);
5859
assert(new Integer(3) != new Integer(3));
5960

6061
String a = "x";
62+
String sa = new String("x");
63+
6164
assert("xxx" == "xx" + "x");
6265
assert("xxx" == ("xx" + a).intern());
6366

@@ -249,13 +252,17 @@ private static void testIdentity() {
249252

250253
System.out.println("HashMap should have 9 members:");
251254
HashMap<Object, Object> hm = new HashMap<>();
255+
256+
hm.put("testing", "testing4"); // same
257+
assert(hm.get(new String("testing")) == "testing4");
258+
259+
hm.clear();
252260

253261
hm.put(new String("testing"), "testing1"); // same
254262
hm.put("testing", "testing2"); // same
255263
String ing = "ing";
256-
hmi.put("test" + ing, "testing3"); // same
264+
hm.put("test" + ing, "testing3"); // same
257265
hm.put("testing", "testing4"); // same
258-
259266

260267
try {
261268
hm.put(new Integer(null), "126new"); // unique

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11485,6 +11485,17 @@ if (database == "_" && J2S._serverUrl.indexOf("//your.server.here/") >= 0) {
1148511485
".bin?", ".smol?", ".spartan?", ".mrc?", ".pse?", ".map?",
1148611486
".omap?", ".dcd?", ".mp3?", ".ogg?", ".wav?", ".au?" ];
1148711487

11488+
J2S.addBinaryFileType = function(ext) {
11489+
if (!ext.indexOf(".") == 0)
11490+
ext = "." + ext;
11491+
if (!ext.indexOf("?") == ext.length - 1)
11492+
ext += "?";
11493+
for (var i = J2S._binaryTypes.length; --i >= 0;)
11494+
if (J2S._binaryTypes[i] == ext)
11495+
return;
11496+
J2S._binaryTypes.push(ext);
11497+
}
11498+
1148811499
J2S.isBinaryUrl = function(url) {
1148911500
url = url.toLowerCase() + "?";
1149011501
for (var i = J2S._binaryTypes.length; --i >= 0;)

0 commit comments

Comments
 (0)