0

I am working in a translator that receive relational algebra expressions and translates them into SQL queries, I've already made the translator code, but I'm having some trouble validating the user's inputs.

The translator works with buttons that insert a default expression in the text area and gives the user a blank space to enter some parameters, here's an example:

 Seleccionar(-the user enters parameters here-)( -the user enters parameters here- )

Is there a way to make the word "Seleccionar" and the brackets read-only? So the user can't edit the default expressions?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Possible duplicate of [Make parts of a JTextArea non editable (not the whole JTextArea!)](http://stackoverflow.com/questions/10030477/make-parts-of-a-jtextarea-non-editable-not-the-whole-jtextarea) – Frakcool Apr 01 '17 at 00:36

2 Answers2

2

Is there a way to make the word "Seleccionar" and the brackets read-only? So the user can't edit the default expressions?

Check out the Protected Text Component. It allows you to prevent multiple areas of text from being changed.

The implementation uses a custom DocumentFilter and NavigationFilter to implement the custom functionality.

camickr
  • 321,443
  • 19
  • 166
  • 288
0

Checkout this plugin Input Mask Plugin. It supports regex mask. You can use a regex like /Seleccionar\(.*?\)\(.*?\)/g to validate your input. Other way to go about is to simply use a separate input for each individual parameter.

VinPro
  • 882
  • 1
  • 6
  • 10