EVALUATION
This can be accomplished by creating your own View to render the frame sets. I'm moving this over to an RFE as this is really a request for additional API to make this easier.
scott.violet@eng 2001-07-12
===============================
This RFE has received little interest by the development
community since its submittal. It is being closed as "Will
Not Fix". Should there be an renewed interest in this request,
it will be considered for re-opening.
###@###.### 2001-11-13
It is not possible simply change view for frames only. It would require to rewrite all HtmlEditorKit.HtmlFactory. This is not very nice solution and maybe there is some room for any enhancement. So please fix at least problem with NPE from setMargin when FrameView is not correctly initialized.
###@###.### 2001-11-14
Agree. Thank you Radim for the fix you have sent me. I have changed it a bit to keep backward compatibiltiy.
To turn editor kit inheritance on:
editorPane.putClientProperty("JEditorPane.inheritEditorKit",Boolean.TRUE);
If you want to have customized editor kit for text/html in your JEditorPane here are the suggested steps:
editorPane.setEditorKitForContentType("text/html",customizedEditorKit);
editorPane.putClientProperty("JEditorPane.inheritEditorKit",Boolean.TRUE);
Will it do for you?
###@###.### 2003-07-29
---
After going back and forth with the fix. I have decided to make this
behavior the default one. having the exceptional property for logical
behavior is irrational.
editorPane.setEditorKitForContentType("text/html",customizedEditorKit);
That is the only thing to do to have customizedEditorKit inerited by frames.
###@###.### 2003-09-03
|
SUGGESTED FIX
It is almost the same fix Radim Kubacki has suggested.
--
*** /tmp/geta29971 Tue Jul 29 17:00:27 2003
--- FrameView.java Tue Jul 29 16:55:41 2003
***************
*** 54,69 ****
try {
URL base = ((HTMLDocument)elem.getDocument()).getBase();
src = new URL(base, srcAtt);
- htmlPane = new JEditorPane();
- htmlPane.addHyperlinkListener(this);
JEditorPane host = getHostPane();
if (host != null) {
- htmlPane.setEditable(host.isEditable());
String charset = (String) host.getClientProperty("charset");
if (charset != null) {
htmlPane.putClientProperty("charset", charset);
}
}
htmlPane.setPage(src);
Document doc = htmlPane.getDocument();
if (doc instanceof HTMLDocument) {
--- 54,79 ----
try {
URL base = ((HTMLDocument)elem.getDocument()).getBase();
src = new URL(base, srcAtt);
JEditorPane host = getHostPane();
if (host != null) {
String charset = (String) host.getClientProperty("charset");
+ Boolean inheritEditorKit = (Boolean) host.getClientProperty("JEditorPane.inheritEditorKit");
+ if (inheritEditorKit != null
+ && inheritEditorKit == Boolean.TRUE) {
+ htmlPane = new FrameEditorPane();
+ htmlPane.putClientProperty("JEditorPane.inheritEditorKit", Boolean.TRUE);
+ System.out.println("FrameView putClientProperty");
+ } else {
+ htmlPane = new JEditorPane();
+ }
if (charset != null) {
htmlPane.putClientProperty("charset", charset);
}
+ htmlPane.setEditable(host.isEditable());
+ } else {
+ htmlPane = new JEditorPane();
}
+ htmlPane.addHyperlinkListener(this);
htmlPane.setPage(src);
Document doc = htmlPane.getDocument();
if (doc instanceof HTMLDocument) {
***************
*** 375,379 ****
--- 385,404 ----
return Integer.MAX_VALUE;
}
+ /** Editor pane rendering frame of HTML document
+ * It uses the same kit as outermost JEditorPane
+ */
+ private class FrameEditorPane extends JEditorPane {
+ public EditorKit getEditorKitForContentType(String type) {
+ JEditorPane outerMostJeditorPane;
+ if (htmlPane.getClientProperty("JEditorPane.inheritEditorKit") != null
+ && (outerMostJeditorPane = getOutermostJEditorPane()) != null) {
+ return outerMostJeditorPane.getEditorKitForContentType(type);
+ } else {
+ return super.getEditorKitForContentType(type);
+ }
+ }
+ }
+
}
---
see evaluation for more details
###@###.### 2003-07-29
----
After going back and forth with the fix. I have decided to make this
behavior the default one. having the exceptional property for logical
behavior is irrational
---
*** /home/kid/work/tests/4479072/webrev/src/share/classes/javax/swing/text/html/FrameView.java- Tue Sep 2 22:06:57 2003
--- FrameView.java Tue Sep 2 20:26:46 2003
***************
*** 52,62 ****
if ((srcAtt != null) && (!srcAtt.equals(""))) {
try {
URL base = ((HTMLDocument)elem.getDocument()).getBase();
src = new URL(base, srcAtt);
! htmlPane = new JEditorPane();
htmlPane.addHyperlinkListener(this);
JEditorPane host = getHostPane();
if (host != null) {
htmlPane.setEditable(host.isEditable());
String charset = (String) host.getClientProperty("charset");
--- 52,62 ----
if ((srcAtt != null) && (!srcAtt.equals(""))) {
try {
URL base = ((HTMLDocument)elem.getDocument()).getBase();
src = new URL(base, srcAtt);
! htmlPane = new FrameEditorPane();
htmlPane.addHyperlinkListener(this);
JEditorPane host = getHostPane();
if (host != null) {
htmlPane.setEditable(host.isEditable());
String charset = (String) host.getClientProperty("charset");
***************
*** 373,379 ****
--- 373,396 ----
*/
public float getMaximumSpan(int axis) {
return Integer.MAX_VALUE;
}
+ /** Editor pane rendering frame of HTML document
+ * It uses the same editor kits classes as outermost JEditorPane
+ */
+ private class FrameEditorPane extends JEditorPane {
+ public EditorKit getEditorKitForContentType(String type) {
+ EditorKit editorKit = super.getEditorKitForContentType(type);
+ JEditorPane outerMostJEditorPane = null;
+ if ((outerMostJEditorPane = getOutermostJEditorPane()) != null) {
+ EditorKit inheritedEditorKit = outerMostJEditorPane.getEditorKitForContentType(type);
+ if (! editorKit.getClass().equals(inheritedEditorKit.getClass())) {
+ editorKit = (EditorKit) inheritedEditorKit.clone();
+ setEditorKitForContentType(type, editorKit);
+ }
+ }
+ return editorKit;
+ }
+ }
}
---
###@###.### 2003-09-03
|