Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2004

Tip: Looking for answers? Try searching our database.

Problem of JTable and the JComboBox cell editor.

Thread view: 
MaoXuePeng - 09 Oct 2004 12:20 GMT
I made a JTable object named tabel And set one of its columns with
JComboBox as CellEditor. When mouse clicked on the JComboBox cell, code
"table.getSelectedRow()" returns -1, and not return the row number until I
selected one of the JComboBox's items. What Wrong?

Now I want to get the row number with "table.getSelectRow" while clicked
on the JComboBox cell immediately, how can I do?

Thanks.
MaoXuePeng
Tor Iver Wilhelmsen - 09 Oct 2004 13:03 GMT
> I made a JTable object named tabel And set one of its columns with
> JComboBox as CellEditor. When mouse clicked on the JComboBox cell,
> code "table.getSelectedRow()" returns -1, and not return the row
> number until I selected one of the JComboBox's items. What Wrong?

Sounds like you test the value before the row is actually selected in
the model.

> Now I want to get the row number with "table.getSelectRow" while
> clicked on the JComboBox cell immediately, how can I do?

You need to "wait" until the model has been updated. Where do you call
getSelectedRow() in your code? If you use a custom CellEditor, use the
passed row index in getTableCellEditorComponent().
MaoXuePeng - 10 Oct 2004 02:08 GMT
> Where do you call getSelectedRow() in your code?
I call getSelectedRow in the function "actionPerformed(ActionEvent event)"
of the JComboBox.
The problem is : When clicked on the JComboBox column, then fired a action
event, but the "getSelectedRow()" returns -1.

> Sounds like you test the value before the row is actually > selected in
the model.

You mean When clicked on the JComboBox column, the table model didn't know
a row was selected? But, actually, there is a row in the table was
selected.

How can I get the row number when click on the JComboBox column by
"getSelectedRow()" in the "actionPerformed()" function?

Thanks!
MaoXuePeng.
Christian Kaufhold - 14 Oct 2004 15:44 GMT
> I made a JTable object named tabel And set one of its columns with
> JComboBox as CellEditor. When mouse clicked on the JComboBox cell, code
[quoted text clipped - 3 lines]
> Now I want to get the row number with "table.getSelectRow" while clicked
> on the JComboBox cell immediately, how can I do?

Please post compilable code that clarifies what you want to do.

Christian
Signature

And in short, I was afraid.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.