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 / April 2006

Tip: Looking for answers? Try searching our database.

multiple selection in JTable without CTRL key

Thread view: 
Chanchal - 17 Apr 2006 12:59 GMT
hi,

is there anyway to make multiple selection in a JTable witout holding
the ctrl key. Please advice. Any code example will be of serious help

thanks in advance

Chanchal
Oliver Wong - 17 Apr 2006 16:55 GMT
> is there anyway to make multiple selection in a JTable witout holding
> the ctrl key. Please advice. Any code example will be of serious help

   Have you considered using a checkbox in a cell to show which rows are
"selected" and which aren't? There's examples of this in
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

   - Oliver
Chanchal - 18 Apr 2006 05:03 GMT
HI Oliver,

thanks for the reply. But it's not rows that i need to select. i need
to select individual cells
Can this solution be used there also

Chanchal
Oliver Wong - 18 Apr 2006 14:06 GMT
> HI Oliver,
>
> thanks for the reply. But it's not rows that i need to select. i need
> to select individual cells
> Can this solution be used there also

   Yes, the same "checkbox" solution could be used by writing a custom cell
renderer which adds a checkbox to every cell, but it's probably too much
trouble.

   What you could do is add a boolean field for every column in your table
model which indicates whether a given column in a particular row was
selected, and then add mouse listeners to detect clicks, toggling this
boolean field.

   But maybe it's better to take a step back and think about why you need
to select individual cells, and why CTRL is not a viable option.

   - Oliver
Chanchal - 19 Apr 2006 05:40 GMT
Hello Oliver,

thanks again for the replay. The reason why ctrl is not a viable option
is that i'm developing a touch screen application. Hence i don't have a
keyboard

Chanchal
Oliver Wong - 19 Apr 2006 14:30 GMT
> The reason why ctrl is not a viable option
> is that i'm developing a touch screen application. Hence i don't have a
> keyboard

   Okay, I'd probably go with the mouse listener setting flags on the model
then.

   - Oliver
Chanchal - 20 Apr 2006 05:58 GMT
could you provide me with some sample code. That will be really
helpful.

Thanks in advance

Chanchal
Chanchal - 19 Apr 2006 05:41 GMT
Hello Oliver,

thanks again for the replay. The reason why ctrl is not a viable option
is that i'm developing a touch screen application. Hence i don't have a
keyboard

Chanchal


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.