equal
deleted
inserted
replaced
22 * or visit www.oracle.com if you need additional information or have any |
22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 package javax.swing; |
25 package javax.swing; |
26 |
26 |
27 import sun.swing.SwingUtilities2; |
|
28 |
|
29 import java.awt.*; |
27 import java.awt.*; |
30 import java.awt.event.*; |
28 import java.beans.JavaBean; |
|
29 import java.beans.BeanProperty; |
31 import java.lang.reflect.*; |
30 import java.lang.reflect.*; |
32 import java.net.*; |
31 import java.net.*; |
33 import java.util.*; |
32 import java.util.*; |
34 import java.io.*; |
33 import java.io.*; |
35 import java.util.*; |
|
36 |
34 |
37 import javax.swing.plaf.*; |
35 import javax.swing.plaf.*; |
38 import javax.swing.text.*; |
36 import javax.swing.text.*; |
39 import javax.swing.event.*; |
37 import javax.swing.event.*; |
40 import javax.swing.text.html.*; |
38 import javax.swing.text.html.*; |
182 * the same version of Swing. As of 1.4, support for long term storage |
180 * the same version of Swing. As of 1.4, support for long term storage |
183 * of all JavaBeans™ |
181 * of all JavaBeans™ |
184 * has been added to the <code>java.beans</code> package. |
182 * has been added to the <code>java.beans</code> package. |
185 * Please see {@link java.beans.XMLEncoder}. |
183 * Please see {@link java.beans.XMLEncoder}. |
186 * |
184 * |
187 * @beaninfo |
|
188 * attribute: isContainer false |
|
189 * description: A text component to edit various types of content. |
|
190 * |
|
191 * @author Timothy Prinzing |
185 * @author Timothy Prinzing |
192 * @since 1.2 |
186 * @since 1.2 |
193 */ |
187 */ |
|
188 @JavaBean(defaultProperty = "UIClassID", description = "A text component to edit various types of content.") |
|
189 @SwingContainer(false) |
194 @SuppressWarnings("serial") // Same-version serialization only |
190 @SuppressWarnings("serial") // Same-version serialization only |
195 public class JEditorPane extends JTextComponent { |
191 public class JEditorPane extends JTextComponent { |
196 |
192 |
197 /** |
193 /** |
198 * Creates a new <code>JEditorPane</code>. |
194 * Creates a new <code>JEditorPane</code>. |
321 * |
317 * |
322 * @return all of the <code>HyperLinkListener</code>s added or an empty |
318 * @return all of the <code>HyperLinkListener</code>s added or an empty |
323 * array if no listeners have been added |
319 * array if no listeners have been added |
324 * @since 1.4 |
320 * @since 1.4 |
325 */ |
321 */ |
|
322 @BeanProperty(bound = false) |
326 public synchronized HyperlinkListener[] getHyperlinkListeners() { |
323 public synchronized HyperlinkListener[] getHyperlinkListeners() { |
327 return listenerList.getListeners(javax.swing.event.HyperlinkListener.class); |
324 return listenerList.getListeners(javax.swing.event.HyperlinkListener.class); |
328 } |
325 } |
329 |
326 |
330 /** |
327 /** |
409 * |
406 * |
410 * @param page the URL of the page |
407 * @param page the URL of the page |
411 * @exception IOException for a <code>null</code> or invalid |
408 * @exception IOException for a <code>null</code> or invalid |
412 * page specification, or exception from the stream being read |
409 * page specification, or exception from the stream being read |
413 * @see #getPage |
410 * @see #getPage |
414 * @beaninfo |
411 */ |
415 * description: the URL used to set content |
412 @BeanProperty(expert = true, description |
416 * bound: true |
413 = "the URL used to set content") |
417 * expert: true |
|
418 */ |
|
419 public void setPage(URL page) throws IOException { |
414 public void setPage(URL page) throws IOException { |
420 if (page == null) { |
415 if (page == null) { |
421 throw new IOException("invalid url"); |
416 throw new IOException("invalid url"); |
422 } |
417 } |
423 URL loaded = getPage(); |
418 URL loaded = getPage(); |
893 * |
888 * |
894 * @return the string "EditorPaneUI" |
889 * @return the string "EditorPaneUI" |
895 * @see JComponent#getUIClassID |
890 * @see JComponent#getUIClassID |
896 * @see UIDefaults#getUI |
891 * @see UIDefaults#getUI |
897 */ |
892 */ |
|
893 @BeanProperty(bound = false) |
898 public String getUIClassID() { |
894 public String getUIClassID() { |
899 return uiClassID; |
895 return uiClassID; |
900 } |
896 } |
901 |
897 |
902 /** |
898 /** |
958 * for plain text, <code>text/plain</code>. |
954 * for plain text, <code>text/plain</code>. |
959 * |
955 * |
960 * @param type the non-<code>null</code> mime type for the content editing |
956 * @param type the non-<code>null</code> mime type for the content editing |
961 * support |
957 * support |
962 * @see #getContentType |
958 * @see #getContentType |
963 * @beaninfo |
|
964 * description: the type of content |
|
965 * @throws NullPointerException if the <code>type</code> parameter |
959 * @throws NullPointerException if the <code>type</code> parameter |
966 * is <code>null</code> |
960 * is <code>null</code> |
967 */ |
961 */ |
|
962 @BeanProperty(bound = false, description |
|
963 = "the type of content") |
968 public final void setContentType(String type) { |
964 public final void setContentType(String type) { |
969 // The type could have optional info is part of it, |
965 // The type could have optional info is part of it, |
970 // for example some charset info. We need to strip that |
966 // for example some charset info. We need to strip that |
971 // of and save it. |
967 // of and save it. |
972 int parm = type.indexOf(';'); |
968 int parm = type.indexOf(';'); |
1044 * to be called on behalf of the caller to ensure integrity |
1040 * to be called on behalf of the caller to ensure integrity |
1045 * of the internal state.</em> |
1041 * of the internal state.</em> |
1046 * |
1042 * |
1047 * @param kit the desired editor behavior |
1043 * @param kit the desired editor behavior |
1048 * @see #getEditorKit |
1044 * @see #getEditorKit |
1049 * @beaninfo |
1045 */ |
1050 * description: the currently installed kit for handling content |
1046 @BeanProperty(expert = true, description |
1051 * bound: true |
1047 = "the currently installed kit for handling content") |
1052 * expert: true |
|
1053 */ |
|
1054 public void setEditorKit(EditorKit kit) { |
1048 public void setEditorKit(EditorKit kit) { |
1055 EditorKit old = this.kit; |
1049 EditorKit old = this.kit; |
1056 isUserSetEditorKit = true; |
1050 isUserSetEditorKit = true; |
1057 if (old != null) { |
1051 if (old != null) { |
1058 old.deinstall(this); |
1052 old.deinstall(this); |
1412 * string. |
1406 * string. |
1413 * |
1407 * |
1414 * @param t the new text to be set; if <code>null</code> the old |
1408 * @param t the new text to be set; if <code>null</code> the old |
1415 * text will be deleted |
1409 * text will be deleted |
1416 * @see #getText |
1410 * @see #getText |
1417 * @beaninfo |
1411 */ |
1418 * description: the text of this component |
1412 @BeanProperty(bound = false, description |
1419 */ |
1413 = "the text of this component") |
1420 public void setText(String t) { |
1414 public void setText(String t) { |
1421 try { |
1415 try { |
1422 Document doc = getDocument(); |
1416 Document doc = getDocument(); |
1423 doc.remove(0, doc.getLength()); |
1417 doc.remove(0, doc.getLength()); |
1424 if (t == null || t.equals("")) { |
1418 if (t == null || t.equals("")) { |
1464 * <code>Scrollable</code> to match the width of the viewport. |
1458 * <code>Scrollable</code> to match the width of the viewport. |
1465 * |
1459 * |
1466 * @return true if a viewport should force the Scrollables width to |
1460 * @return true if a viewport should force the Scrollables width to |
1467 * match its own, false otherwise |
1461 * match its own, false otherwise |
1468 */ |
1462 */ |
|
1463 @BeanProperty(bound = false) |
1469 public boolean getScrollableTracksViewportWidth() { |
1464 public boolean getScrollableTracksViewportWidth() { |
1470 Container parent = SwingUtilities.getUnwrappedParent(this); |
1465 Container parent = SwingUtilities.getUnwrappedParent(this); |
1471 if (parent instanceof JViewport) { |
1466 if (parent instanceof JViewport) { |
1472 JViewport port = (JViewport) parent; |
1467 JViewport port = (JViewport) parent; |
1473 TextUI ui = getUI(); |
1468 TextUI ui = getUI(); |
1487 * |
1482 * |
1488 * @return true if a viewport should force the |
1483 * @return true if a viewport should force the |
1489 * <code>Scrollable</code>'s height to match its own, |
1484 * <code>Scrollable</code>'s height to match its own, |
1490 * false otherwise |
1485 * false otherwise |
1491 */ |
1486 */ |
|
1487 @BeanProperty(bound = false) |
1492 public boolean getScrollableTracksViewportHeight() { |
1488 public boolean getScrollableTracksViewportHeight() { |
1493 Container parent = SwingUtilities.getUnwrappedParent(this); |
1489 Container parent = SwingUtilities.getUnwrappedParent(this); |
1494 if (parent instanceof JViewport) { |
1490 if (parent instanceof JViewport) { |
1495 JViewport port = (JViewport) parent; |
1491 JViewport port = (JViewport) parent; |
1496 TextUI ui = getUI(); |
1492 TextUI ui = getUI(); |
1624 * A new AccessibleJEditorPane instance is created if necessary. |
1620 * A new AccessibleJEditorPane instance is created if necessary. |
1625 * |
1621 * |
1626 * @return an AccessibleJEditorPane that serves as the |
1622 * @return an AccessibleJEditorPane that serves as the |
1627 * AccessibleContext of this JEditorPane |
1623 * AccessibleContext of this JEditorPane |
1628 */ |
1624 */ |
|
1625 @BeanProperty(bound = false) |
1629 public AccessibleContext getAccessibleContext() { |
1626 public AccessibleContext getAccessibleContext() { |
1630 if (getEditorKit() instanceof HTMLEditorKit) { |
1627 if (getEditorKit() instanceof HTMLEditorKit) { |
1631 if (accessibleContext == null || accessibleContext.getClass() != |
1628 if (accessibleContext == null || accessibleContext.getClass() != |
1632 AccessibleJEditorPaneHTML.class) { |
1629 AccessibleJEditorPaneHTML.class) { |
1633 accessibleContext = new AccessibleJEditorPaneHTML(); |
1630 accessibleContext = new AccessibleJEditorPaneHTML(); |