0

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?

Halbort
  • 742
  • 1
  • 6
  • 19

1 Answers1

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.

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045