Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable for accepting data  RSS feed

 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we use JTable to accept data from users? I want to display 4 columns out of 4,three columns should serve the purpose of Jlabels and last column should accept data(Jtext field) from user.Are there any alternatives for this?

Regards
Sudhakar
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Can we use JTable to accept data from users?

how many rows?
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how many rows?


Actually it depends on what table is displayed.Some tables have 8 rows and some have upto 50 rows.

Thanks for your reply.

Regards
Sudhakar
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just make the first 3 columns uneditable - the last column will accept data fine
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you can achieve that by creating your own TableModel (extending DefaultTableModel is the easiest) and implementing / overriding isCellEditable as follows:

Most other methods are just fine; the two methods I override the most are isCellEditable and getColumnClass (e.g. to return Boolean.class so a check box is used).
[ December 13, 2008: Message edited by: Rob Prime ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!