• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help in JTable..

 
fiddy chan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to display a JTable in a frame and set the JTable as read-only Table?
pls help me.. i seriously need help for that to complete my project.. thanks alot..
 
Dhanush Dharsh
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fiddy,
You can use a JScrollPane to display a table. Put the JTable in a JScrollPane and put tha JScrollPane into a JFrame.
Coming to non-editable JTable, I am afraid you have to create your own table model for that. Look below for a simple example.

DefaultTableModel is a very simplistic model with little flexibility, the flexibility comes from being able to plug in your own table model.
Hope this helps.
 
Chris Jebaraj
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about making the JTable's setEditable(false)??? Will it work? i guess so. Pls try out and let us know.
 
fiddy chan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is where i out the "setEditable(false);
but it didn't work. error occured. it can be resolve.
is there another method?
JTable table = new JTable(expenseList, colExpense);
JScrollPane scrollPane = new JScrollPane(table);
setEditable(false);
thanks alot for ur reply.. thanks..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic