•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 426,790 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,772 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 18618 | Replies: 3
![]() |
•
•
Join Date: Jun 2004
Posts: 604
Reputation:
Rep Power: 6
Solved Threads: 6
Hi everyone,
It really depends on what your default editor component is
if your component is say a JTextArea the do the following
One more thing do not forget to add a table listener so that no matter which cell is clicked it cannot be edited or in your initialization you can do a loop an set all cells to uneditble mode
I you have any other questions on this subject post them here
Richard West
It really depends on what your default editor component is
if your component is say a JTextArea the do the following
textarea1 = (JTextArea)table1.getEditorComponent(); textarea1.setEditable(false);
One more thing do not forget to add a table listener so that no matter which cell is clicked it cannot be edited or in your initialization you can do a loop an set all cells to uneditble mode
I you have any other questions on this subject post them here
Richard West
•
•
Join Date: Jul 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
I guess you can implement the isEditable() method in your table model and return false and you table will not be editable. Let's see a quick example
public class MyTableModel extends AbstractTableModel{
public void isEditable(){
return false;
}
}
Then you have a table and you set its model to a MyTableModel object eg.
JTable table = new JTable();
table.setModel(new MyTableModel());
Remember to implement MyTableModel well so that it will have some data. I hope this helps
I guess you can implement the isEditable() method in your table model and return false and you table will not be editable. Let's see a quick example
public class MyTableModel extends AbstractTableModel{
public void isEditable(){
return false;
}
}
Then you have a table and you set its model to a MyTableModel object eg.
JTable table = new JTable();
table.setModel(new MyTableModel());
Remember to implement MyTableModel well so that it will have some data. I hope this helps
AbstractTableModel.isCellEditable(int,int) returns false by default, so you don't need to override it to get that behavior.
The DefaultTableModel implementation of that method returns true by default, so that one must be overriden if you wish to make cells un-editable.
(And the post you are responding to is over 3 years old...)
The DefaultTableModel implementation of that method returns true by default, so that one must be overriden if you wish to make cells un-editable.
(And the post you are responding to is over 3 years old...)
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- new to Swing, JTable questions (Java)
- JTable Cell Renderers (Java)
- make css apply to a chunk of html (HTML and CSS)
- html template help (HTML and CSS)
- HTML Template Help... (HTML and CSS)
- H1 tag problem. (Site Layout and Usability)
- DreamweaverMX 2004 Pro- Plague of Layout Problems (Site Layout and Usability)
Other Threads in the Java Forum
- Previous Thread: Stuck: Exception Handling and reading text from file
- Next Thread: send sms message from pc to mobile



Linear Mode