Skip to content

Commit 5278c9f

Browse files
committed
JEditorPane fix w/o HTMLEditorKit
1 parent b20672f commit 5278c9f

File tree

9 files changed

+19
-17
lines changed

9 files changed

+19
-17
lines changed
8 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200314141453
1+
20200314182519
8 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200314141453
1+
20200314182519
8 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/javax/swing/JEditorPane.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,8 @@ public Dimension getPreferredSize() {
14371437
@Override
14381438
public void setText(String t) {
14391439
try {
1440-
this.秘jsHTMLHelper.setText(t);
1440+
if (秘jsHTMLHelper != null)
1441+
秘jsHTMLHelper.setText(t);
14411442
Document doc = getDocument();
14421443
doc.remove(0, doc.getLength());
14431444
if (t == null || t.equals("")) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ public boolean handleJSEvent(Object target, int eventType, Object jQueryEvent) {
104104
String left = href.substring(0, pt);
105105
elem = getElementFromHref(left);
106106
href = trimHRef(href.substring(pt + 9));
107-
108-
url = new URL(href);
107+
url = new URL(doc.getBase(), href);
109108
} catch (MalformedURLException e) {
110109
// ignore -- could be anything the developer wants.
111110
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,13 @@ public void actionPerformed(ActionEvent e) {
335335
public void actionPerformed(ActionEvent e) {
336336
System.out.println("Test_Editor action " + getID(e.getSource()));
337337
editor.setText("");
338-
JFrame frame1 = new JFrame();
339-
frame1.setLocationRelativeTo(finalB);
340-
JPanel jp = new JPanel();
341-
jp.setPreferredSize(new Dimension(150,150));
342-
frame1.add(jp);
343-
frame1.pack();
344-
frame1.setVisible(true);
338+
// JFrame frame1 = new JFrame();
339+
// frame1.setLocationRelativeTo(finalB);
340+
// JPanel jp = new JPanel();
341+
// jp.setPreferredSize(new Dimension(150,150));
342+
// frame1.add(jp);
343+
// frame1.pack();
344+
// frame1.setVisible(true);
345345

346346
// btop.setEnabled(!btop.isEnabled());
347347
}
@@ -419,7 +419,7 @@ public void actionPerformed(ActionEvent e) {
419419
@Override
420420
public void actionPerformed(ActionEvent e) {
421421
System.out.println("Test_Editor action " + getID(e.getSource()));
422-
area.setCaretPosition(area1.getText().length());
422+
area.setCaretPosition(area.getText().length());
423423
area.requestFocus();
424424
}
425425

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public Test_Html() {
2222
editor.setEditorKit(new HTMLEditorKit());
2323
editor.setText(
2424
"<html>"
25-
+ "<head>"
25+
+ "<head><base href=http://phet.colorado.edu>"
2626
+ "<style type=\"text/css\">"
2727
+ "body { margin:10px 10px 10px 10px;font-size: 24pt; font-family: Dialog }"
2828
+ "a { text-decoration:none;font-size:12pt;}"
@@ -31,8 +31,8 @@ public Test_Html() {
3131
+ "<body>"
3232
+ "<b><font color=red>PhET Interactive Simulations</font></b>"
3333
+ "<br>Copyright &copy; 2004-2015 University of Colorado."
34-
+ "<br><a href=http://phet.colorado.edu/about/licensing.php>Some rights reserved.</a>"
35-
+ "<br>Visit <a href=http://phet.colorado.edu>http://phet.colorado.edu</a>"
34+
+ "<br><a href=\"about/licensing.php\">Some rights reserved.</a>"
35+
+ "<br>Visit <a href=\".\">http://phet.colorado.edu</a>"
3636
+ " <a href=proxy-href>proxy</a>"
3737
+ "</body>"
3838
+ "</html>");
@@ -58,9 +58,11 @@ public void hyperlinkUpdate(HyperlinkEvent e) {
5858

5959
});
6060
HTMLDocument doc = (HTMLDocument)editor.getDocument();
61+
URL base = doc.getBase();
62+
System.out.println("Test_Html base=" + base);
6163
Iterator iter = doc.getIterator(HTML.Tag.A);
6264
while(iter.isValid()) {
63-
System.out.println(iter.getAttributes());
65+
System.out.println("Test_Html a=" + iter.getAttributes());
6466
iter.next();
6567
}
6668

0 commit comments

Comments
 (0)