A
A
Ann As2016-01-17 18:03:05
Java
Ann As, 2016-01-17 18:03:05

Why does getLineCount() count differently?

Hello.
In my first graphics program (text editor) I want to display a line counter.
The same line of code counts differently in two cases:
- when the program starts, the correct count is ;
- when loading a text file, the function counts by one less.

// obj_jlabLineCount - метка в которой все вывожу
// obj_jtaMAIN - компонент JTextArea
obj_jlabLineCount.setText("Line(s): " + (obj_jtaMAIN.getLineCount()));

I don't want to branch because I think it's stupid.
P.s. 1: I didn't find anything on Stackoverflow and docs.oracle.com.
P.s. 2: question on Stackoverflow with sample code
Ps. 3: problem solved - recreated the text file

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abs0lut, 2016-01-17
@abs0lut

obj_jtaMAIN

my eyes...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question