Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JTable single row selection

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, can anyone tell me if it is possible to allow a single row selection please? I want them to select one single row at any one time to ensure 1 record booking. Multiple selection can be misleading. I have been looking throught APIs and can't find anything useful. Thanks for any help/suggestion.
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marlene Miller:
Hi Anna,

The Java Swing Tutorial describes how to specify that only one row at a time can be selected. Here is how I navigated through the Tutorial to find the section:

http://java.sun.com/docs/books/tutorial/uiswing/index.html
The Java Swing Tutorial

http://java.sun.com/docs/books/tutorial/uiswing/components/index.html
Using Swing Components

http://java.sun.com/docs/books/tutorial/uiswing/components/componentlist.html
How To�

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
How To Use Tables

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#selection
Detecting User Selections

Since I have the book and a marker on the JTable section, I just flipped through the pages. It's easier to find that way .

Regards, Marlene

[ October 09, 2004: Message edited by: Marlene Miller ]




I know the search is more than half the fun, but late on a Saturday night

does the trick.
 
Anna Hays
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you! It is working. I have chosen the wrong mode before. D'oh!

Another question, about ListSelectionLister registered for a JTable. The valueChanged action is triggered twice when a selection is made, one for pressing and the other for releasing the mouse button. Why is that? How can I make it only trigger once for any changed selection?
 
Anna Hays
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This is the line if anyone is interested.
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anna Kafei:
Hi, can anyone tell me if it is possible to allow a single row selection please? I want them to select one single row at any one time to ensure 1 record booking. Multiple selection can be misleading. I have been looking throught APIs and can't find anything useful. Thanks for any help/suggestion.



Hi, Anna. In addition to single selection, I found that my JTable allowed ths user to edit text in its cells. To get rid of this behavior I had to overwrite the AbstractTableModel and there to overwrite the isCellEditable(int, int) method to always return false.

Sorry if this is not helpful. It was helpful to me in the general sum of questions related to the JTable functioning.
 
Anna Hays
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. No need to be sorry. It is great to share knowledge.
 
Uh oh, we're definitely being carded. Here, show him this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic