Any Java Experts Here With Jtable Experience?
<div class="IPBDescription">I could use some help.</div> Here's what's going on:
I've been programming a swing/awt-based Java interface for an Access database for a school assignment. I was supposed to make a program that can display data from the database for the user so he/she can add, remove or modify entries and perform searches on it. I chose JTable to present the data in an easily readable format. The program currently works well, considering that this is the first bigger project I've ever done with Java. However, I have two problems I haven't been able to solve and decided to ask if anyone else knew what to do.
1) The JTable component allows the user to drag and drop the columns in the table, thus making rearranging them possible. This doesn't affect the program in any way, because it only affects the graphical display of the data, not the data itself, so no parts of the code that refer to a specific location in the table get confused if the columns are rearranged. However, I'd like to prevent the user from moving the columns. Is this possible, and if it is, how?
2) Currently the user can edit the data by double clicking on any cell of the table. However, the program will get stuck if this is done since there is no code to implement the changes done in the table (i.e. relay them to the database) and the user cannot get out of the cell editing mode once it's initialized. I would like to deny this possibility altogether and make the cells non-editable. I can't make the table completely impervious to clicking, since the 'remove' and 'modify' classes I've created require rows to be selected in order to function. Is there a way to deny only the cell editing?
Thank you for your time, and if you have any ideas, please do tell me. I'm all out of them myself.
I've been programming a swing/awt-based Java interface for an Access database for a school assignment. I was supposed to make a program that can display data from the database for the user so he/she can add, remove or modify entries and perform searches on it. I chose JTable to present the data in an easily readable format. The program currently works well, considering that this is the first bigger project I've ever done with Java. However, I have two problems I haven't been able to solve and decided to ask if anyone else knew what to do.
1) The JTable component allows the user to drag and drop the columns in the table, thus making rearranging them possible. This doesn't affect the program in any way, because it only affects the graphical display of the data, not the data itself, so no parts of the code that refer to a specific location in the table get confused if the columns are rearranged. However, I'd like to prevent the user from moving the columns. Is this possible, and if it is, how?
2) Currently the user can edit the data by double clicking on any cell of the table. However, the program will get stuck if this is done since there is no code to implement the changes done in the table (i.e. relay them to the database) and the user cannot get out of the cell editing mode once it's initialized. I would like to deny this possibility altogether and make the cells non-editable. I can't make the table completely impervious to clicking, since the 'remove' and 'modify' classes I've created require rows to be selected in order to function. Is there a way to deny only the cell editing?
Thank you for your time, and if you have any ideas, please do tell me. I'm all out of them myself.