• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTable question

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I have a question on my GUI design.
I create a JTable to show the requested data, add a new column which allows the user to input the amount of seats he wants to book, and a button to update the data to db.db and refresh the JTable.
The question is : after editing the cell, I have to move the cursor in order to fire the set value method of my table model, and save the data to a vector. if i don't do that(move the cursor) and just click the button, no data would be stored in the vector.
Any suggestion?
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add a JTextBox as the table cell editor, add change listener to the JTextBox and update the Vector. But why?
An easier design would be to provide a JTextBox outside the JTable. User can select a row and enter the seats in the JTextBox which is shown outside the JTable. This is easy compared to the current design and a junior programmer can understand!
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Sam J"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark
 
Sam Jason
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, sai
thanks for your suggestion, but since JRadioButton coultn't be used in JTable, how could I force the user choice only one row at a time?
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sam,
You can use the JRadioButton in the JTable cell if you use your own renderer.
Can you use the method "setSelectionMode(int selectionMode)" in JTable?
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sam Jason:
how could I force the user choice only one row at a time?[/QB]


I used this line of code:
 
reply
    Bookmark Topic Watch Topic
  • New Topic