38 |
|
|
39 |
package javax.swing; |
package javax.swing; |
40 |
|
|
41 |
|
import java.awt.Dimension; |
42 |
import java.awt.FontMetrics; |
import java.awt.FontMetrics; |
43 |
|
import java.awt.Rectangle; |
44 |
|
|
45 |
import javax.swing.text.BadLocationException; |
import javax.swing.text.BadLocationException; |
46 |
import javax.swing.text.Document; |
import javax.swing.text.Document; |
232 |
} |
} |
233 |
|
|
234 |
/** |
/** |
235 |
|
* Returns the increment that is needed to expose exactly one new line |
236 |
|
* of text. This is implemented here to return the values of |
237 |
|
* {@link #getRowHeight} and {@link getColumnWidth}, depending on |
238 |
|
* the value of the argument <code>direction</code>. |
239 |
|
* |
240 |
|
* @param visibleRect the view area that is visible in the viewport |
241 |
|
* @param orientation either {@link SwingConstants.VERTICAL} or |
242 |
|
* {@link SwingConstants.HORIZONTAL} |
243 |
|
* @param direction less than zero for up/left scrolling, greater |
244 |
|
* than zero for down/right scrolling |
245 |
|
* |
246 |
|
* @return the increment that is needed to expose exactly one new row |
247 |
|
* or column of text |
248 |
|
* |
249 |
|
* @throws IllegalArgumentException if <code>orientation</code> is invalid |
250 |
|
*/ |
251 |
|
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, |
252 |
|
int direction) |
253 |
|
{ |
254 |
|
if (orientation == SwingConstants.VERTICAL) |
255 |
|
return getRowHeight(); |
256 |
|
else if (orientation == SwingConstants.HORIZONTAL) |
257 |
|
return getColumnWidth(); |
258 |
|
else |
259 |
|
throw new IllegalArgumentException("orientation must be either " |
260 |
|
+ "javax.swing.SwingConstants.VERTICAL " |
261 |
|
+ "or " |
262 |
|
+ "javax.swing.SwingConstants.HORIZONTAL" |
263 |
|
); |
264 |
|
} |
265 |
|
|
266 |
|
/** |
267 |
|
* Returns the preferred size of that text component in the case |
268 |
|
* it is embedded within a JScrollPane. This uses the column and |
269 |
|
* row settings if they are explicitly set, or fall back to |
270 |
|
* the superclass's behaviour. |
271 |
|
* |
272 |
|
* @return the preferred size of that text component in the case |
273 |
|
* it is embedded within a JScrollPane |
274 |
|
*/ |
275 |
|
public Dimension getPreferredScrollableViewportSize() |
276 |
|
{ |
277 |
|
if ((rows > 0) && (columns > 0)) |
278 |
|
return new Dimension(columns * getColumnWidth(), rows * getRowHeight()); |
279 |
|
else |
280 |
|
return super.getPreferredScrollableViewportSize(); |
281 |
|
} |
282 |
|
|
283 |
|
/** |
284 |
* Returns the UI class ID string. |
* Returns the UI class ID string. |
285 |
* |
* |
286 |
* @return the string "TextAreaUI" |
* @return the string "TextAreaUI" |