473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Notepad program

539 512MB
Im currently doing my project "sukatoa notepad"!!! and im inspired to code it for that it looks like windows notepad... and it is 97 percent complete!!!

But i get stucked of the last part, "Counting the lines" (update the caretPosition);

Ive formulated 4 algorithms that will count the lines '\n' from the textArea....
those four algorithms is sucks when it is greater than 210 lines...
I mean the performance starts to slow after 100th lines...
(I used it to update the Line position)/(On what line is my caretPosition now!!!)
Calling that method from textAreaKeyReleased event....

Ive test those algorithms by this example...

The quick brown fox jump over the lazy dog.(new line) times 800...

I need your advice and idea how you implement the fastest way to count the lines...(for updating lines starts from zero to the last character where the caret positioned.... getCaretPosition)....

Which is the best Event to call my future method(Update what line)?(keyPressed or KeyReleased?).....

if you have the algorithm, can you show it?!!

Thank you so much Experts!!!

I will appreciate any reply...
Dec 1 '07 #1
4 1703
JosAH
11,448 Expert 8TB
Use a CaretListener on your JTextArea; each time the caret position changes
an event will be fired. In the listener check the JTextArea for the line and column
positions; it has convenience methods for that. Never use low level events when
high level semantic events are available for the same purpose. A Key event is
a low level event; a Caret event is a high level event.

kind regards,

Jos
Dec 1 '07 #2
sukatoa
539 512MB
It really works!!!

Thanks Jos!!! Project Finished!!!
Looks like the same time interval at line 10 to line 879... So fast...
no logging!!!

=)

Thank you!!!....
Dec 1 '07 #3
JosAH
11,448 Expert 8TB
It really works!!!

Thanks Jos!!! Project Finished!!!
Looks like the same time interval at line 10 to line 879... So fast...
no logging!!!

=)

Thank you!!!....
You're welcome of course. Did you add an UndoManager yet? Such a thing is
very convenient and easy to add to your enhanced JTextArea.

kind regards,

Jos
Dec 1 '07 #4
sukatoa
539 512MB
You're welcome of course. Did you add an UndoManager yet? Such a thing is
very convenient and easy to add to your enhanced JTextArea.

kind regards,

Jos
Not yet!! Yah, Swing textArea have no Undo shortCut!! (ctrl z)....
i don't know about Undo Manager in JTextArea...

I will study it first!!! Thanks again...

99%complete!!
Dec 2 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: aa | last post by:
I write to a text file, and when view the resulting file in Notepad, it shows "\t" as tabs correctly, but "\n" does not break the line. Instad it shows as a square. In Dreamweaver it shows OK....
1
by: Roger | last post by:
I've got some MS-windows (XP only?) related questions; hopefully someone can give me some advise. 1) Is there some way to make notepad to become the front window when it is started from within...
4
by: Jesper | last post by:
How can I open a textfile from C# using notepad (or the user assigned application for this).
2
by: Kueishiong Tu | last post by:
I have a window form application. My program generates a report. I want to invoke the window notepad program to show the report. How do I do that?
7
by: kisshug | last post by:
hi i'm working on project.in that i have 2 call notepad.exe. i want to know how to call notepad.exe from a c program in unix environment -- kisshug Message posted via ...
13
by: Chris Johnson | last post by:
I have what seems to be such a simple thing yet I cannot figure out how to do it. I am using a streamwriter to build a text file. At the end of the process I want to open that same text file in...
5
by: MoshiachNow | last post by:
HI, How do I force a browser to open a certain file with notepad ? <LI><A HREF="D:/Program Files/yohoLogFile.txt.4" ><p style="font-family:font-size: 7pt;"yohoLogFile.txt.4 </A></LI>'; ...
9
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have this code for sendKeys. This simply sends a text to the notepad. This method runs fine, but I don't see the notepad and the text entered in that notepad. Is there any way...
6
by: sanjayhpatel2000 | last post by:
Hi Everybody, I am new to Python and also new to Notepad++. Can any one help to code my first python program in Notepad++. I am already doing it in python interpretor, but now i was to do in...
36
by: Don | last post by:
I wrote an app that alerts a user who attempts to open a file that the file is currently in use. It works fine except when the file is opened by Notepad. If a text file is opened, most computers...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.