Parenthesis matching in swings

Hi,

I want to implement a parenthesis matching functionality in swings.

Whenever I click on any "}" OR "{", text area till the matching parenthesis should ger selected.

This functionality is same as in any Java IDE for example eclipse.

Please help!

Regards,

himani.

[308 byte] By [Himani123a] at [2007-11-26 21:42:54]
# 1

do it like this:

on click:

step1: - check if char a curser is "{"

step2if so, search from that location until text end for "}"

step3if found select text from curser position to found position

if not found, do something else

the specific methods can be found in the api http://java.sun.com/j2se/1.5.0/docs/api/index.html?javax/swing/package-summary.html

caution: if you want to select cascaded parenthesis like this {{{{}}}} correctly, add a counter to the algorithm above: count +=1 for every "{" during step2 and modify step3:if found and count=0 select text.... if found and cound >0: make count -= 1

EDIT: this is the algorithm for selecting "{"'s but its similar for "}" 's..the only diffrence might be searching from curser to 0....

Message was edited by:

jEti182

jEti182a at 2007-7-10 3:29:28 > top of Java-index,Desktop,Core GUI APIs...