I want to create a dialog box that consists of one column of field titles and another column of fields. I want to be able to specify the fields to only allow specific types of data. Using swing, what is the most idiomatic way of creating a reusable class for accomplishing this?
Asked
Active
Viewed 62 times
1 Answers
2
A shown in Validating Input, you can use an InputVerifier
to restrict input; a complete example is examined here. In the particular case of columnar data, a JTable
can choose the editor based on the underlying model's data type—the value returned by getColumnClass()
. You can let the editor validate user-entered text in your implementation of stopCellEditing()
, illustrated here. In either case, you can add a panel containing the input component(s) to a dialog, as outlined here.