Re: Getting programmatic access to EOTABLE (JTable) in NonDirect2JC...
Re: Getting programmatic access to EOTABLE (JTable) in NonDirect2JC...
- Subject: Re: Getting programmatic access to EOTABLE (JTable) in NonDirect2JC...
- From: Jean Pierre Malrieu <email@hidden>
- Date: Tue, 2 Dec 2003 21:51:20 +0100
> Hello friends
>
> Is it possible to get prog. access to the EO's in a JTable?
> I already have access to the columns and rows (primitive data).
> I need the selected EO, because I want to send it via RMI to the
> server...
>
> Is TableModel the right way?
>
> Thank you
> Oliver
If this is a EOTable, created by means of IB, then you have a display
group (and association) and you get the selection from there.
If this is a pure JTable, created by the swing api then you need to use
the swing api.
I paste below a piece of the swing tutorials about JTable (can't give
you the url, but you'll find it easily).
JP.
Detecting User Selections
The following code snippet shows how to detect when the user selects a
table row. By default, a table allows the user to select multiple rows
-- not columns or individual cells -- and the selected rows need not be
next to each other. Using thesetSelectionMode method, the following
code specifies that only one row at a time can be selected. You can
find the entire program in SimpleTableSelectionDemo.java
[demime 0.98b removed an attachment of type image/tiff which had a name of image.tiff]
.
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
...
ListSelectionModel rowSM = table.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
//Ignore extra messages.
if (e.getValueIsAdjusting()) return;
ListSelectionModel lsm =
(ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
...//no rows are selected
} else {
int selectedRow = lsm.getMinSelectionIndex();
...//selectedRow is selected
}
}
});
SimpleTableSelectionDemo.java
[demime 0.98b removed an attachment of type image/tiff which had a name of image.tiff]
also has code (not included in the preceding snippet) that changes the
table's selection orientation. By changing a couple of boolean values,
you can make the table allow either column selections or individual
cell selections, instead of row selections.
For more information and examples of implementing selection, see How to
Write a List Selection Listener.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.