![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e985. Setting the Tab Size of a JTextArea ComponentWhen a tab character (\t) is inserted into a text area, it is represented by a space that is wide enough to reach the next tab stop. The space expands or contracts, if the text preceding it is modified. A tab space cannot be zero-width or wider than a tab stop.By default, each tab stop is the same width and appears at regular intervals. The tab stop width is controlled by the \meta{tab size}. The tab size specifies a number of characters. The tab width is this value multiplied by the maximal character width in the current font. For example, if the widest character in the current font is 20 pixels and the tab size is 8, the tab width is 160 pixels; tab stops will appear every 160 pixels in the text area. All tab stops in a // Create a text area JTextArea textarea = new JTextArea(); // Get the default tab size int tabSize = textarea.getTabSize(); // 8 // Change the tab size tabSize = 4; textarea.setTabSize(tabSize); Font font = textarea.getFont();
e983. Modifying Text in a JTextArea Component e984. Enumerating the Lines in a JTextArea Component e986. Moving the Focus with the TAB Key in a JTextArea Component e987. Enabling Word-Wrapping and Line-Wrapping in a JTextArea Component e988. Implementing a Console Window with a JTextArea Component
© 2002 Addison-Wesley. |