Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

Running It

We have a class, BracketMatcher, that listens to the caret. We just need to apply it to a JTextComponent of some sort, to get it running:

JEditorPane p = new JEditorPane();
p.addCaretListener(new BracketMatcher());

Put that in a JFrame, and it looks like Figures 3 and 4.

Figure 3Figure 3 A highlighted document.

Figure 4Figure 4 Incorrect matching.

  • + Share This
  • 🔖 Save To Your Account