< prev index next >

src/java.desktop/share/classes/javax/swing/JTextArea.java

Print this page

        

*** 37,93 **** import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.io.IOException; /** ! * A <code>JTextArea</code> is a multi-line area that displays plain text. * It is intended to be a lightweight component that provides source ! * compatibility with the <code>java.awt.TextArea</code> class where it can * reasonably do so. * You can find information and examples of using all the text components in * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/text.html">Using Text Components</a>, * a section in <em>The Java Tutorial.</em> * * <p> * This component has capabilities not found in the ! * <code>java.awt.TextArea</code> class. The superclass should be * consulted for additional capabilities. * Alternative multi-line text classes with ! * more capabilities are <code>JTextPane</code> and <code>JEditorPane</code>. * <p> ! * The <code>java.awt.TextArea</code> internally handles scrolling. ! * <code>JTextArea</code> is different in that it doesn't manage scrolling, ! * but implements the swing <code>Scrollable</code> interface. This allows it ! * to be placed inside a <code>JScrollPane</code> if scrolling * behavior is desired, and used directly if scrolling is not desired. * <p> ! * The <code>java.awt.TextArea</code> has the ability to do line wrapping. * This was controlled by the horizontal scrolling policy. Since ! * scrolling is not done by <code>JTextArea</code> directly, backward ! * compatibility must be provided another way. <code>JTextArea</code> has * a bound property for line wrapping that controls whether or * not it will wrap lines. By default, the line wrapping property * is set to false (not wrapped). * <p> ! * <code>java.awt.TextArea</code> has two properties <code>rows</code> ! * and <code>columns</code> that are used to determine the preferred size. ! * <code>JTextArea</code> uses these properties to indicate the ! * preferred size of the viewport when placed inside a <code>JScrollPane</code> ! * to match the functionality provided by <code>java.awt.TextArea</code>. ! * <code>JTextArea</code> has a preferred size of what is needed to * display all of the text, so that it functions properly inside of ! * a <code>JScrollPane</code>. If the value for <code>rows</code> ! * or <code>columns</code> is equal to zero, * the preferred size along that axis is used for * the viewport preferred size along the same axis. * <p> ! * The <code>java.awt.TextArea</code> could be monitored for changes by adding ! * a <code>TextListener</code> for <code>TextEvent</code>s. ! * In the <code>JTextComponent</code> based * components, changes are broadcasted from the model via a ! * <code>DocumentEvent</code> to <code>DocumentListeners</code>. ! * The <code>DocumentEvent</code> gives * the location of the change and the kind of change if desired. * The code fragment might look something like: * <pre> * DocumentListener myListener = ??; * JTextArea myArea = ??; --- 37,93 ---- import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.io.IOException; /** ! * A {@code JTextArea} is a multi-line area that displays plain text. * It is intended to be a lightweight component that provides source ! * compatibility with the {@code java.awt.TextArea} class where it can * reasonably do so. * You can find information and examples of using all the text components in * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/text.html">Using Text Components</a>, * a section in <em>The Java Tutorial.</em> * * <p> * This component has capabilities not found in the ! * {@code java.awt.TextArea} class. The superclass should be * consulted for additional capabilities. * Alternative multi-line text classes with ! * more capabilities are {@code JTextPane} and {@code JEditorPane}. * <p> ! * The {@code java.awt.TextArea} internally handles scrolling. ! * {@code JTextArea} is different in that it doesn't manage scrolling, ! * but implements the swing {@code Scrollable} interface. This allows it ! * to be placed inside a {@code JScrollPane} if scrolling * behavior is desired, and used directly if scrolling is not desired. * <p> ! * The {@code java.awt.TextArea} has the ability to do line wrapping. * This was controlled by the horizontal scrolling policy. Since ! * scrolling is not done by {@code JTextArea} directly, backward ! * compatibility must be provided another way. {@code JTextArea} has * a bound property for line wrapping that controls whether or * not it will wrap lines. By default, the line wrapping property * is set to false (not wrapped). * <p> ! * {@code java.awt.TextArea} has two properties {@code rows} ! * and {@code columns} that are used to determine the preferred size. ! * {@code JTextArea} uses these properties to indicate the ! * preferred size of the viewport when placed inside a {@code JScrollPane} ! * to match the functionality provided by {@code java.awt.TextArea}. ! * {@code JTextArea} has a preferred size of what is needed to * display all of the text, so that it functions properly inside of ! * a {@code JScrollPane}. If the value for {@code rows} ! * or {@code columns} is equal to zero, * the preferred size along that axis is used for * the viewport preferred size along the same axis. * <p> ! * The {@code java.awt.TextArea} could be monitored for changes by adding ! * a {@code TextListener} for {@code TextEvent}s. ! * In the {@code JTextComponent} based * components, changes are broadcasted from the model via a ! * {@code DocumentEvent} to {@code DocumentListeners}. ! * The {@code DocumentEvent} gives * the location of the change and the kind of change if desired. * The code fragment might look something like: * <pre> * DocumentListener myListener = ??; * JTextArea myArea = ??;
*** 111,121 **** * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @beaninfo * attribute: isContainer false * description: A multi-line area that displays plain text. --- 111,121 ---- * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. * * @beaninfo * attribute: isContainer false * description: A multi-line area that displays plain text.
*** 294,304 **** /** * Sets the line-wrapping policy of the text area. If set * to true the lines will be wrapped if they are too long * to fit within the allocated width. If set to false, ! * the lines will always be unwrapped. A <code>PropertyChange</code> * event ("lineWrap") is fired when the policy is changed. * By default this property is false. * * @param wrap indicates if lines should be wrapped * @see #getLineWrap --- 294,304 ---- /** * Sets the line-wrapping policy of the text area. If set * to true the lines will be wrapped if they are too long * to fit within the allocated width. If set to false, ! * the lines will always be unwrapped. A {@code PropertyChange} * event ("lineWrap") is fired when the policy is changed. * By default this property is false. * * @param wrap indicates if lines should be wrapped * @see #getLineWrap
*** 648,658 **** /** * Returns a string representation of this JTextArea. This method * is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not ! * be <code>null</code>. * * @return a string representation of this JTextArea. */ protected String paramString() { String wrapString = (wrap ? --- 648,658 ---- /** * Returns a string representation of this JTextArea. This method * is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not ! * be {@code null}. * * @return a string representation of this JTextArea. */ protected String paramString() { String wrapString = (wrap ?
*** 707,718 **** /** * Components that display logical rows or columns should compute * the scroll increment that will completely expose one new row * or column, depending on the value of orientation. This is implemented ! * to use the values returned by the <code>getRowHeight</code> and ! * <code>getColumnWidth</code> methods. * <p> * Scrolling containers, like JScrollPane, will use this method * each time the user requests a unit scroll. * * @param visibleRect the view area visible within the viewport --- 707,718 ---- /** * Components that display logical rows or columns should compute * the scroll increment that will completely expose one new row * or column, depending on the value of orientation. This is implemented ! * to use the values returned by the {@code getRowHeight} and ! * {@code getColumnWidth} methods. * <p> * Scrolling containers, like JScrollPane, will use this method * each time the user requests a unit scroll. * * @param visibleRect the view area visible within the viewport
*** 773,793 **** return accessibleContext; } /** * This class implements accessibility support for the ! * <code>JTextArea</code> class. It provides an implementation of the * Java Accessibility API appropriate to text area user-interface * elements. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") // Same-version serialization only protected class AccessibleJTextArea extends AccessibleJTextComponent { --- 773,793 ---- return accessibleContext; } /** * This class implements accessibility support for the ! * {@code JTextArea} class. It provides an implementation of the * Java Accessibility API appropriate to text area user-interface * elements. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") // Same-version serialization only protected class AccessibleJTextArea extends AccessibleJTextComponent {
< prev index next >