Java Code Examples for javax.swing.JTextArea.getLineCount()

The following are Jave code examples for showing how to use getLineCount() of the javax.swing.JTextArea class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: FinalSpeed   File: LogFrame.java   Source Code and License Vote up 5 votes
public void trunkTextArea(JTextArea txtWin){
    int numLinesToTrunk = txtWin.getLineCount() - SCROLL_BUFFER_SIZE;
    if(numLinesToTrunk > 0)
    {
        try
        {
            int posOfLastLineToTrunk = txtWin.getLineEndOffset(numLinesToTrunk - 1);
            txtWin.replaceRange("",0,posOfLastLineToTrunk);
        }
        catch (BadLocationException ex) {
            ex.printStackTrace();
        }
    }
}