> I can't even go that far since JTable has its own problems. Like you
> mentioned its hard to customize without creating your own component and
> its also almost useless for data entry. In general the whole thing is
> missing so much basical functionality that you end up spending all your
> time subclassing their components. Little things like the simplest of
> data validation (limiting the number of characters entered for instance)
> require you to write code when it should be basic functionality of the
> component.
I'm afraid that isn't true. The reason why there is no functionality for
data validation (like entering only numbers) is that a JTable can contain
in essence anything you'd like. You could for example make a JTable of
regular expressions or of names that have to belong to a database ...
Each of these needs a totally different validation routine. It's
therefor clear that this validation should not be directly included in the
JTable but should be customizable.
The way this customization can be done for a JTable is by using the
concept of "CellRenderer" and "CellEditor". A CellRenderer controls the
way your data is visualized. For example, if you have a JTable field that
contains a multiple choice of which the first choice is at present
selected, the CellRenderer could visualize that by creating a JPanel
containing RadioButtons. If the first multiple choice is selected, the
first RadioButton is visualized as having been pressed. In the same way,
if you are entering data, a CellEditor is used as a component that
receives your input and verifies if it is correct. If so, the data is
entered into the datamodel of your JTable and visualised using a
CellRenderer. A very flexible system indeed ...
Mark Christiaens
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]