How can I check the parameters without creating a separate dialog?
I am about to make an application (in Swing) that uses a tree to render a data structure (JTree). The tree will be on the left side of the window. The user will be able to view the tree. The parameters of each tree node will be displayed on the right side of the window. The example windows will look like this:
===========================
| tree panel | data panel |
| | |
| | |
| | |
---------------------------
The problem arises when the user wants to change this data. when should i check them? An easy approach is to open a new modal dialog (JDialog) and let the user modify this data in it. Data validation will be done in "ok" mode, but this is a little awkward. I would like to allow the user to edit this data directly in the data pane. In this case, when should I check them?
Is there an example of such a solution in Swing?
Or any online tutorial on how to do this?
Thanks in advance.
source to share
I'm not really sure what you want, but ..
Perhaps you could add this "ok" button (or "make changes" or whatever) to the data bar and when the button is clicked you will validate the data and save the changes if the changes are valid?
(So ββthere are editable components in the data pane)
Edit: if it wasn't good, could you please clarify a bit:
- Does the data pane display data for one tree item?
- What data needs to be changed (and verified)
Anyway, if you want to check the correctness of the changes made to the editing component (like JTextField), you can use for example
- Formatted text fields, see Using formatted text fields
- For a more general check, see InputVerifier
- For other ideas, see Validating for Numeric Input in JTextField (Numeric Input Concentrates, but used for other purposes)
source to share