Win a copy of Head First Android this week in the Android 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Selecting a row in a JTable using a RadioButton

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I add a column with values to an existing JTable
which has been constructed using a AbstractTableModel.
Basically I have a completely constructed JTable, and for Selection of each row,I want to add a column with a RadioButton.By Selecting this RadioButton,the user selects the particular row.
Plz reply,
poornima.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Best way is to implement ur own model
I don't think it is possible w/o using a custom table model
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I add a column with values to an existing JTable
which has been constructed using a AbstractTableModel.

There is a method which has to be implemented in AbstractTableModel called getColumnCount. Just return one more that the columns are in the database. And then adjust by one your getValueAt() method by one column.
Basically I have a completely constructed JTable, and for Selection of each row,I want to add a column with a RadioButton.By Selecting this RadioButton,the user selects the particular row. Each column's renderer can be changed. Read about the getColumnClass, and setDefaultRenderer methods. But you don't need a radio button to let the user select a row. That behavior is already built into JTable
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic