📄 textarea.java
字号:
* prefer to display, and on the size of the font in which the text * would be displayed. * * @return The minimum size for this text area. * * @deprecated This method is deprecated in favor of * <code>getMinimumSize ()</code>. */ public Dimension minimumSize () { return minimumSize (getRows (), getColumns ()); } /** * Retrieve the minimum size that this text area would have if its * row and column values were equal to those specified. A text * area's minimum size depends on the number of rows and columns of * text it would prefer to display, and on the size of the font in * which the text would be displayed. * * @param rows The number of rows to use in the minimum size * calculation. * @param columns The number of columns to use in the minimum size * calculation. * * @return The minimum size for this text area. * * @deprecated This method is deprecated in favor of * <code>getMinimumSize (int, int)</code>. */ public Dimension minimumSize (int rows, int columns) { TextAreaPeer peer = (TextAreaPeer) getPeer (); // Sun returns Dimension (0,0) in this case. if (peer == null) return new Dimension (0, 0); return peer.getMinimumSize (rows, columns); } /** * Retrieve the preferred size for this text area, considering the * text area's current row and column values. A text area's preferred * size depends on the number of rows and columns of text it would * prefer to display, and on the size of the font in which the text * would be displayed. * * @return The preferred size for this text field. */ public Dimension getPreferredSize () { return getPreferredSize (getRows (), getColumns ()); } /** * Retrieve the preferred size that this text area would have if its * row and column values were equal to those specified. A text * area's preferred size depends on the number of rows and columns * of text it would prefer to display, and on the size of the font * in which the text would be displayed. * * @param rows The number of rows to use in the preferred size * calculation. * @param columns The number of columns to use in the preferred size * calculation. * * @return The preferred size for this text area. */ public Dimension getPreferredSize (int rows, int columns) { return preferredSize (rows, columns); } /** * Retrieve the preferred size for this text area, considering the * text area's current row and column values. A text area's preferred * size depends on the number of rows and columns of text it would * prefer to display, and on the size of the font in which the text * would be displayed. * * @return The preferred size for this text field. * * @deprecated This method is deprecated in favor of * <code>getPreferredSize ()</code>. */ public Dimension preferredSize () { return preferredSize (getRows (), getColumns ()); } /** * Retrieve the preferred size that this text area would have if its * row and column values were equal to those specified. A text * area's preferred size depends on the number of rows and columns * of text it would prefer to display, and on the size of the font * in which the text would be displayed. * * @param rows The number of rows to use in the preferred size * calculation. * @param columns The number of columns to use in the preferred size * calculation. * * @return The preferred size for this text area. * * @deprecated This method is deprecated in favor of * <code>getPreferredSize (int, int)</code>. */ public Dimension preferredSize (int rows, int columns) { TextAreaPeer peer = (TextAreaPeer) getPeer (); // Sun returns Dimension (0,0) in this case. if (peer == null) return new Dimension (0, 0); return peer.getPreferredSize (rows, columns); } /** * Retrieve the scroll bar display policy -- one of SCROLLBARS_BOTH, * SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY, * SCROLLBARS_NONE. * * @return The current scroll bar display policy. */ public int getScrollbarVisibility () { return scrollbarVisibility; } /** * Notify this object that it should create its native peer. */ public void addNotify () { if (getPeer () == null) setPeer ((ComponentPeer) getToolkit().createTextArea (this)); } /** * Append the specified text to the end of the current text. * * @param str The text to append. */ public void append (String str) { appendText (str); } /** * Append the specified text to the end of the current text. * * @param str The text to append. * * @deprecated This method is deprecated in favor of * <code>append ()</code>. */ public void appendText (String str) { TextAreaPeer peer = (TextAreaPeer) getPeer (); if (peer != null) peer.insert (str, peer.getText().length ()); } /** * Insert the specified text at the specified position. The first * character in the text area is at position zero. * * @param str The text to insert. * @param pos The position at which to insert text. */ public void insert (String str, int pos) { insertText (str, pos); } /** * Insert the specified text at the specified position. The first * character in the text area is at position zero. * * @param str The text to insert. * @param pos The position at which to insert text. * * @deprecated This method is deprecated in favor of * <code>insert ()</code>. */ public void insertText (String str, int pos) { TextAreaPeer peer = (TextAreaPeer) getPeer (); if (peer != null) peer.insert (str, pos); } /** * Replace a range of characters with the specified text. The * character at the start position will be replaced, unless start == * end. The character at the end posistion will not be replaced. * The first character in the text area is at position zero. The * length of the replacement text may differ from the length of the * text that is replaced. * * @param str The new text for the range. * @param start The start position of the replacement range. * @param end The end position of the replacement range. */ public void replaceRange (String str, int start, int end) { replaceText (str, start, end); } /** * Replace a range of characters with the specified text. The * character at the start position will be replaced, unless start == * end. The character at the end posistion will not be replaced. * The first character in the text area is at position zero. The * length of the replacement text may differ from the length of the * text that is replaced. * * @param str The new text for the range. * @param start The start position of the replacement range. * @param end The end position of the replacement range. * * @deprecated This method is deprecated in favor of * <code>replaceRange ()</code>. */ public void replaceText (String str, int start, int end) { TextAreaPeer peer = (TextAreaPeer) getPeer (); if (peer != null) peer.replaceRange (str, start, end); } /** * Retrieve a debugging string for this text area. * * @return A debugging string for this text area. */ protected String paramString () { String sbVisibility = ""; switch (scrollbarVisibility) { case SCROLLBARS_BOTH: sbVisibility = "both"; break; case SCROLLBARS_VERTICAL_ONLY: sbVisibility = "vertical-only"; break; case SCROLLBARS_HORIZONTAL_ONLY: sbVisibility = "horizontal-only"; break; case SCROLLBARS_NONE: sbVisibility = "none"; break; } String editable = ""; if (isEditable ()) editable = "editable,"; return getName () + "," + getX () + "," + getY () + "," + getWidth () + "x" + getHeight () + "," + "text=" + getText () + "," + editable + "selection=" + getSelectionStart () + "-" + getSelectionEnd () + ",rows=" + rows + ",columns=" + columns + ",scrollbarVisibility=" + sbVisibility; } /** * Generate a unique name for this text area. * * @return A unique name for this text area. */ String generateName () { return "text" + getUniqueLong (); } private static synchronized long getUniqueLong () { return next_text_number++; } protected class AccessibleAWTTextArea extends AccessibleAWTTextComponent { private static final long serialVersionUID = 3472827823632144419L; protected AccessibleAWTTextArea() { } public AccessibleStateSet getAccessibleStateSet() { return super.getAccessibleStateSet(); } } /** * Gets the AccessibleContext associated with this <code>TextArea</code>. * The context is created, if necessary. * * @return the associated context */ public AccessibleContext getAccessibleContext() { /* Create the context if this is the first request */ if (accessibleContext == null) accessibleContext = new AccessibleAWTTextArea(); return accessibleContext; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -