JTextArea addressArea;
By default, the text area is set up without scroll bars. To add scroll bars, you create a JScrollPane object then add the text area to the JScrollPane object. So declare a JScrollPane object, for example
JScrollPane addressPane;
Then invoke the javax.swing.JTextArea constructor, for example
addressArea = new JTextArea(3,12);
where the constructor arguments specify the minimum number of rows and columns in the text area itself. Now add addressArea to a scrollpane using the JScrollPane constructor, as follows:
addressPane = new JScrollPane(addressArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS and JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS indicate that the vertical and horizontal scrollbars are always visible. The default is to show no scrollbars until the text area becomes full with text entered by the user.
No comments:
Post a Comment